├── gba-core ├── src │ ├── audio │ │ ├── mod.rs │ │ └── apu.rs │ ├── script │ │ └── mod.rs │ ├── input │ │ ├── mod.rs │ │ ├── registers.rs │ │ └── joypad.rs │ ├── memory │ │ └── mod.rs │ ├── arm7tdmi │ │ ├── mod.rs │ │ ├── error.rs │ │ ├── symbolizer.rs │ │ ├── mode.rs │ │ └── pipeline.rs │ ├── lib.rs │ └── cartridge │ │ ├── mod.rs │ │ ├── sram.rs │ │ └── storage.rs ├── Cargo.toml └── build.rs ├── .gitattributes ├── debugger ├── src │ ├── dbg │ │ ├── mod.rs │ │ ├── widgets │ │ │ └── mod.rs │ │ ├── tracked_value.rs │ │ └── debugger.rs │ └── event.rs ├── build.rs └── Cargo.toml ├── rustfmt.toml ├── external ├── tonc │ ├── bigmap.gba │ ├── code │ │ ├── adv │ │ │ ├── m7_ex │ │ │ │ ├── gfx │ │ │ │ │ ├── border.grit │ │ │ │ │ ├── karts.grit │ │ │ │ │ ├── thwomp.grit │ │ │ │ │ ├── bgpal.grit │ │ │ │ │ ├── objpal.grit │ │ │ │ │ ├── bgpal.png │ │ │ │ │ ├── karts.png │ │ │ │ │ ├── bc1sky.png │ │ │ │ │ ├── border.png │ │ │ │ │ ├── objpal.png │ │ │ │ │ ├── thwomp.png │ │ │ │ │ ├── bc1floor.grit │ │ │ │ │ ├── bc1floor.png │ │ │ │ │ └── bc1sky.grit │ │ │ │ ├── source │ │ │ │ │ ├── mode7.iwram.c │ │ │ │ │ └── id_sort_shell.s │ │ │ │ └── m7_ex.pnproj │ │ │ ├── m7_demo │ │ │ │ ├── gfx │ │ │ │ │ ├── nums.grit │ │ │ │ │ └── nums.png │ │ │ │ ├── source │ │ │ │ │ └── m7_demo.h │ │ │ │ └── m7_demo.pnproj │ │ │ ├── tte_demo │ │ │ │ ├── gfx │ │ │ │ │ ├── menu_gfx.grit │ │ │ │ │ ├── dlgbox.png │ │ │ │ │ ├── dungeon01.png │ │ │ │ │ ├── menu_gfx.png │ │ │ │ │ ├── dungeon01.grit │ │ │ │ │ └── dlgbox.grit │ │ │ │ ├── tte_demo.ppg │ │ │ │ ├── fonts │ │ │ │ │ ├── yesh1.png │ │ │ │ │ ├── cyber16.png │ │ │ │ │ ├── mssans9.png │ │ │ │ │ ├── tahoma9.png │ │ │ │ │ ├── verdana11.png │ │ │ │ │ ├── fonts.h │ │ │ │ │ ├── yesh1.h │ │ │ │ │ ├── tahoma9.h │ │ │ │ │ ├── verdana11.h │ │ │ │ │ ├── mssans9.h │ │ │ │ │ └── cyber16.h │ │ │ │ └── tte_demo.pnproj │ │ │ ├── txt_se2 │ │ │ │ ├── gba.png │ │ │ │ ├── txt_se2.pnproj │ │ │ │ └── gba_pic.h │ │ │ ├── txt_se1 │ │ │ │ ├── border.png │ │ │ │ ├── txt_se1.pnproj │ │ │ │ └── border.h │ │ │ ├── txt_bm │ │ │ │ └── txt_bm.pnproj │ │ │ └── txt_obj │ │ │ │ └── txt_obj.pnproj │ │ ├── vc8 │ │ │ └── tonc.suo │ │ ├── Makefile │ │ ├── ext │ │ │ ├── obj_aff │ │ │ │ ├── metr.png │ │ │ │ ├── obj_aff.pnproj │ │ │ │ └── metr.h │ │ │ ├── sbb_aff │ │ │ │ ├── nums.png │ │ │ │ ├── sbb_aff.pnproj │ │ │ │ └── nums.h │ │ │ ├── bld_demo │ │ │ │ ├── metr.png │ │ │ │ ├── bld_demo.pnproj │ │ │ │ └── metr.h │ │ │ ├── mos_demo │ │ │ │ ├── metr.png │ │ │ │ ├── mos_demo.pnproj │ │ │ │ ├── metr.h │ │ │ │ └── mos_demo.c │ │ │ ├── oacombo │ │ │ │ ├── oacombo.png │ │ │ │ ├── oacombo.pnproj │ │ │ │ └── oac_gfx.h │ │ │ ├── tmr_demo │ │ │ │ ├── berk.bmp │ │ │ │ ├── tmr_demo.pnproj │ │ │ │ ├── berk.h │ │ │ │ └── tmr_demo.c │ │ │ ├── win_demo │ │ │ │ ├── nums.png │ │ │ │ ├── rocket.png │ │ │ │ ├── win_demo.pnproj │ │ │ │ ├── rocket.h │ │ │ │ ├── rocket.c │ │ │ │ └── nums.h │ │ │ ├── dma_demo │ │ │ │ ├── brin-full.png │ │ │ │ ├── dma_demo.pnproj │ │ │ │ └── brin.h │ │ │ ├── swi_demo │ │ │ │ └── swi_demo.pnproj │ │ │ ├── snd1_demo │ │ │ │ └── snd1_demo.pnproj │ │ │ ├── swi_vsync │ │ │ │ ├── swi_vsync.pnproj │ │ │ │ ├── swi_vsync.c │ │ │ │ └── metr.h │ │ │ └── irq_demo │ │ │ │ └── irq_demo.pnproj │ │ ├── lab │ │ │ ├── bigmap │ │ │ │ ├── link.png │ │ │ │ ├── kakariko.png │ │ │ │ ├── bigmap.pnproj │ │ │ │ ├── link_gfx.h │ │ │ │ ├── kakariko.h │ │ │ │ └── link.h │ │ │ ├── octtest │ │ │ │ ├── octants.png │ │ │ │ ├── turret.png │ │ │ │ ├── octtest.pnproj │ │ │ │ └── octants.h │ │ │ ├── prio_demo │ │ │ │ ├── prio_bg.png │ │ │ │ ├── prio_gfx.png │ │ │ │ ├── prio_demo.pnproj │ │ │ │ ├── prio_gfx.h │ │ │ │ ├── prio.iwram.c │ │ │ │ ├── prio_bg.h │ │ │ │ ├── prio_gfx.c │ │ │ │ └── id_sort_shell2.s │ │ │ └── template │ │ │ │ ├── template.ppg │ │ │ │ ├── template.pnproj │ │ │ │ ├── source │ │ │ │ └── main.c │ │ │ │ └── gba-tonc-fix.sh │ │ ├── tonclib │ │ │ ├── libtonc.chm │ │ │ ├── toncfont.bmp │ │ │ ├── lib │ │ │ │ └── libtonc.a │ │ │ ├── src │ │ │ │ ├── tonc_core.c │ │ │ │ ├── font │ │ │ │ │ ├── sys8.png │ │ │ │ │ ├── verdana10.s │ │ │ │ │ ├── verdana9.s │ │ │ │ │ ├── verdana9b.s │ │ │ │ │ ├── verdana9i.s │ │ │ │ │ ├── verdana10.png │ │ │ │ │ ├── verdana9.png │ │ │ │ │ ├── verdana9_b4.s │ │ │ │ │ ├── verdana9b.png │ │ │ │ │ ├── verdana9i.png │ │ │ │ │ └── verdana9_b4.png │ │ │ │ ├── tonc_video.c │ │ │ │ ├── tonc_math.c │ │ │ │ ├── tonc_bg.c │ │ │ │ ├── tonc_oam.c │ │ │ │ ├── tte │ │ │ │ │ ├── obj_drawg.c │ │ │ │ │ ├── chr4c_drawg_b4cts.c │ │ │ │ │ ├── bmp16_drawg.c │ │ │ │ │ ├── bmp8_drawg.c │ │ │ │ │ ├── chr4c_drawg_b1cts.c │ │ │ │ │ ├── chr4r_drawg_b1cts.c │ │ │ │ │ └── bmp16_drawg_b1cs.c │ │ │ │ └── pre1.3 │ │ │ │ │ └── tonc_text.c │ │ │ ├── include │ │ │ │ ├── tonc_math.h │ │ │ │ ├── tonc_tte.h │ │ │ │ ├── tonc_nocash.h │ │ │ │ └── tonc.h │ │ │ ├── base.h │ │ │ ├── base.c │ │ │ └── asm │ │ │ │ ├── tonc_nocash.s │ │ │ │ ├── tonc_isr_master.s │ │ │ │ ├── clr_fade_fast.s │ │ │ │ └── clr_blend_fast.s │ │ ├── basic │ │ │ ├── key_demo │ │ │ │ ├── gba.png │ │ │ │ ├── key_demo.pnproj │ │ │ │ ├── toolbox.c │ │ │ │ ├── gba_pic.h │ │ │ │ ├── key_demo.c │ │ │ │ └── Makefile │ │ │ ├── obj_demo │ │ │ │ ├── metr.png │ │ │ │ ├── obj_demo.pnproj │ │ │ │ ├── metr.h │ │ │ │ ├── toolbox.c │ │ │ │ ├── Makefile │ │ │ │ └── obj_demo.c │ │ │ ├── bm_modes │ │ │ │ ├── modes.png │ │ │ │ ├── bm_modes.pnproj │ │ │ │ ├── modes.h │ │ │ │ ├── toolbox.c │ │ │ │ ├── bm_modes.c │ │ │ │ └── Makefile │ │ │ ├── cbb_demo │ │ │ │ ├── cbb_ids.png │ │ │ │ ├── cbb_demo.pnproj │ │ │ │ ├── cbb_ids.h │ │ │ │ ├── Makefile │ │ │ │ └── cbb_demo.c │ │ │ ├── pageflip │ │ │ │ ├── page_pic.png │ │ │ │ ├── pageflip.pnproj │ │ │ │ ├── toolbox.c │ │ │ │ ├── pageflip.c │ │ │ │ ├── page_pic.h │ │ │ │ └── Makefile │ │ │ ├── brin_demo │ │ │ │ ├── brin-full.png │ │ │ │ ├── brin_demo.pnproj │ │ │ │ ├── toolbox.c │ │ │ │ ├── brin.h │ │ │ │ ├── brin_demo.c │ │ │ │ └── Makefile │ │ │ ├── first │ │ │ │ ├── first.pnproj │ │ │ │ ├── first.mak │ │ │ │ ├── first.bat │ │ │ │ ├── first.c │ │ │ │ ├── first_msys.bat │ │ │ │ └── Makefile │ │ │ ├── second │ │ │ │ ├── second.pnproj │ │ │ │ ├── second.c │ │ │ │ ├── Makefile │ │ │ │ └── toolbox.h │ │ │ ├── m3_demo │ │ │ │ ├── m3_demo.pnproj │ │ │ │ ├── m3_demo.c │ │ │ │ └── Makefile │ │ │ ├── hello │ │ │ │ ├── hello.pnproj │ │ │ │ ├── hello.c │ │ │ │ └── Makefile │ │ │ └── sbb_reg │ │ │ │ ├── sbb_reg.pnproj │ │ │ │ ├── toolbox.c │ │ │ │ └── Makefile │ │ ├── vc6 │ │ │ └── tonc.dsw │ │ └── tonc.mak │ ├── first.gba │ ├── hello.gba │ ├── m7_ex.gba │ ├── second.gba │ ├── txt_bm.gba │ ├── bld_demo.gba │ ├── bm_modes.gba │ ├── brin_demo.gba │ ├── cbb_demo.gba │ ├── dma_demo.gba │ ├── irq_demo.gba │ ├── key_demo.gba │ ├── m3_demo.gba │ ├── m7_demo.gba │ ├── mos_demo.gba │ ├── oacombo.gba │ ├── obj_aff.gba │ ├── obj_demo.gba │ ├── octtest.gba │ ├── pageflip.gba │ ├── prio_demo.gba │ ├── sbb_aff.gba │ ├── sbb_reg.gba │ ├── snd1_demo.gba │ ├── swi_demo.gba │ ├── swi_vsync.gba │ ├── tmr_demo.gba │ ├── tte_demo.gba │ ├── txt_obj.gba │ ├── txt_se1.gba │ ├── txt_se2.gba │ ├── win_demo.gba │ └── m7_demo_mb.gba ├── dbs │ ├── bios+arm.bndb │ ├── armfuck.gba.bndb │ ├── methharold.gba.bndb │ └── gang-ldmstm.gba.bndb ├── discord │ ├── gang.gba │ ├── panda.gba │ ├── armfuck.gba │ ├── retaddr.gba │ ├── gang-ldmstm.gba │ └── methharold.gba ├── docs │ ├── ARM7TDMI.pdf │ ├── DDI0029.pdf │ ├── ARM7TDMI Data Sheet.pdf │ └── arm-instructionset.pdf ├── games │ └── OpenLara.gba ├── mgba-suite │ └── suite.gba ├── screenshots.zip ├── collect_screenshots.sh └── clean_screenshots.sh ├── rom-db-ui ├── app │ ├── favicon.ico │ ├── globals.css │ ├── layout.tsx │ └── page.tsx ├── postcss.config.mjs ├── next.config.ts ├── package.json ├── .gitignore ├── tsconfig.json └── README.md ├── Cargo.toml ├── .gitignore ├── rom-db └── Cargo.toml ├── scripts ├── scooby_fix_eeprom.rhai ├── example.rhai └── dump_swi.rhai └── .gitmodules /gba-core/src/audio/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod apu; 2 | -------------------------------------------------------------------------------- /gba-core/src/script/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod engine; 2 | mod proxy; 3 | -------------------------------------------------------------------------------- /gba-core/src/input/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod joypad; 2 | pub mod registers; 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | external/screenshots.zip filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /debugger/src/dbg/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod debugger; 2 | mod tracked_value; 3 | pub mod widgets; 4 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | fn_params_layout = "Compressed" 2 | imports_granularity = "Module" 3 | max_width = 120 4 | -------------------------------------------------------------------------------- /external/tonc/bigmap.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/bigmap.gba -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/border.grit: -------------------------------------------------------------------------------- 1 | # 2 | # Menu borders, LZ77 compressed. 3 | # 4 | -gt -gB4 -gzl -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/karts.grit: -------------------------------------------------------------------------------- 1 | # 2 | # Karts. Not compressed. 3 | # 4 | -gt -gB4 -Mw4 -Mh4 -p! -------------------------------------------------------------------------------- /external/tonc/first.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/first.gba -------------------------------------------------------------------------------- /external/tonc/hello.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/hello.gba -------------------------------------------------------------------------------- /external/tonc/m7_ex.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/m7_ex.gba -------------------------------------------------------------------------------- /external/tonc/second.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/second.gba -------------------------------------------------------------------------------- /external/tonc/txt_bm.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/txt_bm.gba -------------------------------------------------------------------------------- /gba-core/src/memory/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod device; 2 | pub mod dma; 3 | pub mod mmio; 4 | pub mod registers; 5 | -------------------------------------------------------------------------------- /external/dbs/bios+arm.bndb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/dbs/bios+arm.bndb -------------------------------------------------------------------------------- /external/discord/gang.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/discord/gang.gba -------------------------------------------------------------------------------- /external/discord/panda.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/discord/panda.gba -------------------------------------------------------------------------------- /external/docs/ARM7TDMI.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/docs/ARM7TDMI.pdf -------------------------------------------------------------------------------- /external/docs/DDI0029.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/docs/DDI0029.pdf -------------------------------------------------------------------------------- /external/games/OpenLara.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/games/OpenLara.gba -------------------------------------------------------------------------------- /external/tonc/bld_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/bld_demo.gba -------------------------------------------------------------------------------- /external/tonc/bm_modes.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/bm_modes.gba -------------------------------------------------------------------------------- /external/tonc/brin_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/brin_demo.gba -------------------------------------------------------------------------------- /external/tonc/cbb_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/cbb_demo.gba -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/thwomp.grit: -------------------------------------------------------------------------------- 1 | # 2 | # Thwomp tiles, LZ77 compressed. 3 | # 4 | -gt -gB4 -p! -Zl -------------------------------------------------------------------------------- /external/tonc/dma_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/dma_demo.gba -------------------------------------------------------------------------------- /external/tonc/irq_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/irq_demo.gba -------------------------------------------------------------------------------- /external/tonc/key_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/key_demo.gba -------------------------------------------------------------------------------- /external/tonc/m3_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/m3_demo.gba -------------------------------------------------------------------------------- /external/tonc/m7_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/m7_demo.gba -------------------------------------------------------------------------------- /external/tonc/mos_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/mos_demo.gba -------------------------------------------------------------------------------- /external/tonc/oacombo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/oacombo.gba -------------------------------------------------------------------------------- /external/tonc/obj_aff.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/obj_aff.gba -------------------------------------------------------------------------------- /external/tonc/obj_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/obj_demo.gba -------------------------------------------------------------------------------- /external/tonc/octtest.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/octtest.gba -------------------------------------------------------------------------------- /external/tonc/pageflip.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/pageflip.gba -------------------------------------------------------------------------------- /external/tonc/prio_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/prio_demo.gba -------------------------------------------------------------------------------- /external/tonc/sbb_aff.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/sbb_aff.gba -------------------------------------------------------------------------------- /external/tonc/sbb_reg.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/sbb_reg.gba -------------------------------------------------------------------------------- /external/tonc/snd1_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/snd1_demo.gba -------------------------------------------------------------------------------- /external/tonc/swi_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/swi_demo.gba -------------------------------------------------------------------------------- /external/tonc/swi_vsync.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/swi_vsync.gba -------------------------------------------------------------------------------- /external/tonc/tmr_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/tmr_demo.gba -------------------------------------------------------------------------------- /external/tonc/tte_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/tte_demo.gba -------------------------------------------------------------------------------- /external/tonc/txt_obj.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/txt_obj.gba -------------------------------------------------------------------------------- /external/tonc/txt_se1.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/txt_se1.gba -------------------------------------------------------------------------------- /external/tonc/txt_se2.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/txt_se2.gba -------------------------------------------------------------------------------- /external/tonc/win_demo.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/win_demo.gba -------------------------------------------------------------------------------- /rom-db-ui/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/rom-db-ui/app/favicon.ico -------------------------------------------------------------------------------- /external/dbs/armfuck.gba.bndb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/dbs/armfuck.gba.bndb -------------------------------------------------------------------------------- /external/discord/armfuck.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/discord/armfuck.gba -------------------------------------------------------------------------------- /external/discord/retaddr.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/discord/retaddr.gba -------------------------------------------------------------------------------- /external/mgba-suite/suite.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/mgba-suite/suite.gba -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_demo/gfx/nums.grit: -------------------------------------------------------------------------------- 1 | # 2 | # nums.png : 8bpp tiles, with palette 3 | # 4 | 5 | -gt -gB8 -pn 32 -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/bgpal.grit: -------------------------------------------------------------------------------- 1 | # 2 | # Background palette, LZ77 compressed. 3 | # 4 | -gB8 -g! -s bg -Zl -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/objpal.grit: -------------------------------------------------------------------------------- 1 | # 2 | # Object palette, LZ77 compressed. 3 | # 4 | -gB8 -g! -s obj -Zl -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/gfx/menu_gfx.grit: -------------------------------------------------------------------------------- 1 | # 2 | # Menu bitmap : 240x16@8, RLE 3 | # 4 | -gb -gB8 -gzr 5 | -q -------------------------------------------------------------------------------- /external/tonc/m7_demo_mb.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/m7_demo_mb.gba -------------------------------------------------------------------------------- /external/dbs/methharold.gba.bndb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/dbs/methharold.gba.bndb -------------------------------------------------------------------------------- /external/discord/gang-ldmstm.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/discord/gang-ldmstm.gba -------------------------------------------------------------------------------- /external/discord/methharold.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/discord/methharold.gba -------------------------------------------------------------------------------- /external/tonc/code/vc8/tonc.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/vc8/tonc.suo -------------------------------------------------------------------------------- /external/dbs/gang-ldmstm.gba.bndb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/dbs/gang-ldmstm.gba.bndb -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/tte_demo.ppg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debugger/build.rs: -------------------------------------------------------------------------------- 1 | use shadow_rs::ShadowBuilder; 2 | 3 | fn main() { 4 | ShadowBuilder::builder().build().unwrap(); 5 | } 6 | -------------------------------------------------------------------------------- /external/docs/ARM7TDMI Data Sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/docs/ARM7TDMI Data Sheet.pdf -------------------------------------------------------------------------------- /external/docs/arm-instructionset.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/docs/arm-instructionset.pdf -------------------------------------------------------------------------------- /external/tonc/code/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # I'm sorry Mario, but our rules are in another makefile :P 3 | # 4 | 5 | include tonc.mak 6 | -------------------------------------------------------------------------------- /rom-db-ui/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | const config = { 2 | plugins: ["@tailwindcss/postcss"], 3 | }; 4 | 5 | export default config; 6 | -------------------------------------------------------------------------------- /external/tonc/code/adv/txt_se2/gba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/txt_se2/gba.png -------------------------------------------------------------------------------- /external/tonc/code/ext/obj_aff/metr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/obj_aff/metr.png -------------------------------------------------------------------------------- /external/tonc/code/ext/sbb_aff/nums.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/sbb_aff/nums.png -------------------------------------------------------------------------------- /external/tonc/code/lab/bigmap/link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/lab/bigmap/link.png -------------------------------------------------------------------------------- /external/tonc/code/tonclib/libtonc.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/libtonc.chm -------------------------------------------------------------------------------- /external/tonc/code/tonclib/toncfont.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/toncfont.bmp -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/bgpal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_ex/gfx/bgpal.png -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/karts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_ex/gfx/karts.png -------------------------------------------------------------------------------- /external/tonc/code/adv/txt_se1/border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/txt_se1/border.png -------------------------------------------------------------------------------- /external/tonc/code/basic/key_demo/gba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/basic/key_demo/gba.png -------------------------------------------------------------------------------- /external/tonc/code/basic/obj_demo/metr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/basic/obj_demo/metr.png -------------------------------------------------------------------------------- /external/tonc/code/ext/bld_demo/metr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/bld_demo/metr.png -------------------------------------------------------------------------------- /external/tonc/code/ext/mos_demo/metr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/mos_demo/metr.png -------------------------------------------------------------------------------- /external/tonc/code/ext/oacombo/oacombo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/oacombo/oacombo.png -------------------------------------------------------------------------------- /external/tonc/code/ext/tmr_demo/berk.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/tmr_demo/berk.bmp -------------------------------------------------------------------------------- /external/tonc/code/ext/win_demo/nums.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/win_demo/nums.png -------------------------------------------------------------------------------- /external/tonc/code/ext/win_demo/rocket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/win_demo/rocket.png -------------------------------------------------------------------------------- /external/tonc/code/lab/bigmap/kakariko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/lab/bigmap/kakariko.png -------------------------------------------------------------------------------- /external/tonc/code/lab/octtest/octants.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/lab/octtest/octants.png -------------------------------------------------------------------------------- /external/tonc/code/lab/octtest/turret.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/lab/octtest/turret.png -------------------------------------------------------------------------------- /external/tonc/code/tonclib/lib/libtonc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/lib/libtonc.a -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tonc_core.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/tonc_core.c -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_demo/gfx/nums.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_demo/gfx/nums.png -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/bc1sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_ex/gfx/bc1sky.png -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_ex/gfx/border.png -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/objpal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_ex/gfx/objpal.png -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/thwomp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_ex/gfx/thwomp.png -------------------------------------------------------------------------------- /external/tonc/code/basic/bm_modes/modes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/basic/bm_modes/modes.png -------------------------------------------------------------------------------- /external/tonc/code/lab/prio_demo/prio_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/lab/prio_demo/prio_bg.png -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/sys8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/sys8.png -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/bc1floor.grit: -------------------------------------------------------------------------------- 1 | # 2 | # Bowser's Castle I floor : affine map, 128x128t, LZ77 compressed. 3 | # 4 | -gB8 -mRa -mLa -p! -Zl -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/bc1floor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_ex/gfx/bc1floor.png -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/gfx/bc1sky.grit: -------------------------------------------------------------------------------- 1 | # 2 | # Bowser's Castle I sky : normal map, 64x32t, LZ77 compressed. 3 | # 4 | -gB4 -mLs -mR4 -ma 128 -p! -Zl -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/yesh1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/tte_demo/fonts/yesh1.png -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/gfx/dlgbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/tte_demo/gfx/dlgbox.png -------------------------------------------------------------------------------- /external/tonc/code/basic/cbb_demo/cbb_ids.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/basic/cbb_demo/cbb_ids.png -------------------------------------------------------------------------------- /external/tonc/code/basic/pageflip/page_pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/basic/pageflip/page_pic.png -------------------------------------------------------------------------------- /external/tonc/code/ext/dma_demo/brin-full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/ext/dma_demo/brin-full.png -------------------------------------------------------------------------------- /external/tonc/code/lab/prio_demo/prio_gfx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/lab/prio_demo/prio_gfx.png -------------------------------------------------------------------------------- /external/tonc/code/tonclib/include/tonc_math.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/include/tonc_math.h -------------------------------------------------------------------------------- /external/tonc/code/tonclib/include/tonc_tte.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/include/tonc_tte.h -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana10.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana10.s -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana9.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana9.s -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana9b.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana9b.s -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana9i.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana9i.s -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/source/mode7.iwram.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/m7_ex/source/mode7.iwram.c -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/cyber16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/tte_demo/fonts/cyber16.png -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/mssans9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/tte_demo/fonts/mssans9.png -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/tahoma9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/tte_demo/fonts/tahoma9.png -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/gfx/dungeon01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/tte_demo/gfx/dungeon01.png -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/gfx/menu_gfx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/tte_demo/gfx/menu_gfx.png -------------------------------------------------------------------------------- /external/tonc/code/basic/brin_demo/brin-full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/basic/brin_demo/brin-full.png -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana10.png -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana9.png -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana9_b4.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana9_b4.s -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana9b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana9b.png -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana9i.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana9i.png -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/verdana11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/adv/tte_demo/fonts/verdana11.png -------------------------------------------------------------------------------- /external/tonc/code/basic/first/first.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/font/verdana9_b4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioncodes/ayyboy-advance/HEAD/external/tonc/code/tonclib/src/font/verdana9_b4.png -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/gfx/dungeon01.grit: -------------------------------------------------------------------------------- 1 | # 2 | # LoZ:LttP, dungeon 1 map : 64x64t, 4bpp, SBB-layout, LZ77 compressed. 3 | # 4 | -gt -gB4 -mR4 -mLs -Zl 5 | -------------------------------------------------------------------------------- /external/screenshots.zip: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0b021e1136190cbfbb511dc431cdff2afeaeb098815eeabe307789a9ce48bc2b 3 | size 958104577 4 | -------------------------------------------------------------------------------- /rom-db-ui/next.config.ts: -------------------------------------------------------------------------------- 1 | import type { NextConfig } from "next"; 2 | 3 | const nextConfig: NextConfig = { 4 | output: "export", 5 | }; 6 | 7 | export default nextConfig; 8 | -------------------------------------------------------------------------------- /external/tonc/code/lab/template/template.ppg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["gba-core", "debugger", "rom-db"] 3 | resolver = "3" 4 | 5 | [profile.release] 6 | debug = true 7 | 8 | [profile.dev] 9 | opt-level = 3 10 | -------------------------------------------------------------------------------- /gba-core/src/arm7tdmi/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cpu; 2 | pub mod decoder; 3 | pub mod error; 4 | mod handlers; 5 | pub mod mode; 6 | mod pipeline; 7 | pub mod registers; 8 | mod symbolizer; 9 | pub mod timer; 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | external/gba_bios.bin 3 | *.log 4 | .DS_Store 5 | .vscode/ 6 | .idea/ 7 | external/commercial/ 8 | Cargo.lock 9 | flamegraph.svg 10 | *.png 11 | rom-db-ui/screenshots/ 12 | .zed/ 13 | # Local Netlify folder 14 | .netlify 15 | saves/ -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/gfx/dlgbox.grit: -------------------------------------------------------------------------------- 1 | # 2 | # dlgbox tiles, column-major tile order. 3 | # 4 | # NOTE : with grit 0.8.1, column-major tiling can be done with -tc. 5 | # In older versions, you can fake it using -Mh(imgHeight/8). 6 | 7 | -gt -gB4 -pn16 -tc -------------------------------------------------------------------------------- /gba-core/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(new_zeroed_alloc)] 2 | 3 | pub mod arm7tdmi; 4 | pub mod audio; 5 | pub mod cartridge; 6 | pub mod gba; 7 | pub mod input; 8 | pub mod memory; 9 | pub mod script; 10 | pub mod video; 11 | 12 | #[cfg(test)] 13 | mod tests; 14 | -------------------------------------------------------------------------------- /external/tonc/code/basic/second/second.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/basic/m3_demo/m3_demo.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/basic/cbb_demo/cbb_demo.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/fonts.h: -------------------------------------------------------------------------------- 1 | // 2 | // Font master header. 3 | // 4 | 5 | #ifndef __FONTS_H__ 6 | #define __FONTS_H__ 7 | 8 | #include "cyber16.h" 9 | #include "mssans9.h" 10 | #include "tahoma9.h" 11 | #include "verdana11.h" 12 | #include "yesh1.h" 13 | 14 | #endif // __FONTS_H__ 15 | 16 | // EOF 17 | -------------------------------------------------------------------------------- /external/tonc/code/basic/hello/hello.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /rom-db/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rom-db" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | zip = { version = "4.0.0", default-features = false, features = ["deflate"] } 8 | gba-core = { path = "../gba-core" } 9 | image = { version = "0.25.6", default-features = false, features = ["png"] } 10 | -------------------------------------------------------------------------------- /external/tonc/code/ext/obj_aff/obj_aff.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/tonc/code/ext/sbb_aff/sbb_aff.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/tonc/code/basic/sbb_reg/sbb_reg.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/ext/bld_demo/bld_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/tonc/code/ext/dma_demo/dma_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/tonc/code/ext/mos_demo/mos_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/tonc/code/ext/swi_demo/swi_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/tonc/code/ext/tmr_demo/tmr_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/tonc/code/ext/snd1_demo/snd1_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/tonc/code/ext/swi_vsync/swi_vsync.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /external/collect_screenshots.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | max_parallel=2 4 | timeout_duration=360 5 | process_executable="./target/release/rom-db" 6 | 7 | export SHELL=$(type -p bash) 8 | 9 | find "$1" \( -iname '*.gba' -o -iname '*.zip' \) | \ 10 | parallel --bar -j "$max_parallel" --line-buffer timeout "$timeout_duration" "$process_executable" {} 11 | -------------------------------------------------------------------------------- /external/tonc/code/basic/bm_modes/bm_modes.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/basic/key_demo/key_demo.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/basic/brin_demo/brin_demo.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/basic/pageflip/pageflip.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/yesh1.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(yesh1) 3 | 4 | #ifndef __YESH1__ 5 | #define __YESH1__ 6 | 7 | // 4x8 Sub-pixel font by JanoS, http://www.haluz.org/yesh/ 8 | 9 | extern const TFont yesh1Font; 10 | 11 | #define yesh1GlyphsLen 6144 12 | extern const unsigned int yesh1Glyphs[1536]; 13 | 14 | #endif // __YESH1__ 15 | 16 | //}}BLOCK(yesh1) 17 | -------------------------------------------------------------------------------- /external/tonc/code/ext/irq_demo/irq_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /gba-core/src/arm7tdmi/error.rs: -------------------------------------------------------------------------------- 1 | use thiserror::Error; 2 | 3 | #[derive(Error, Debug)] 4 | pub enum CpuError { 5 | #[error("CPU is in a paused state")] 6 | CpuPaused, 7 | #[error("Interrupt has been triggered")] 8 | InterruptTriggered, 9 | #[error("Instruction could not be decoded")] 10 | FailedToDecode, 11 | #[error("CPU has nothing to do")] 12 | NothingToDo, 13 | } 14 | -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/tahoma9.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(tahoma9) 3 | 4 | #ifndef __TAHOMA9__ 5 | #define __TAHOMA9__ 6 | 7 | extern const TFont tahoma9Font; 8 | 9 | #define tahoma9GlyphsLen 3584 10 | extern const unsigned int tahoma9Glyphs[896]; 11 | 12 | #define tahoma9WidthsLen 224 13 | extern const unsigned char tahoma9Widths[224]; 14 | 15 | #endif // __TAHOMA9__ 16 | 17 | //}}BLOCK(tahoma9) 18 | -------------------------------------------------------------------------------- /external/tonc/code/ext/win_demo/win_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /rom-db-ui/app/globals.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss"; 2 | 3 | :root { 4 | --background: #ffffff; 5 | --foreground: #171717; 6 | } 7 | 8 | @media (prefers-color-scheme: dark) { 9 | :root { 10 | --background: #0a0a0a; 11 | --foreground: #ededed; 12 | } 13 | } 14 | 15 | body { 16 | background: var(--background); 17 | color: var(--foreground); 18 | font-family: Arial, Helvetica, sans-serif; 19 | } -------------------------------------------------------------------------------- /gba-core/src/cartridge/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::cartridge::storage::BackupType; 2 | use crate::memory::device::{Addressable, Saveable}; 3 | 4 | pub mod database; 5 | pub mod eeprom; 6 | pub mod flash; 7 | pub mod sram; 8 | pub mod storage; 9 | 10 | pub trait StorageChip: Addressable + Saveable { 11 | fn size(&self) -> usize; 12 | fn backup_type(&self) -> BackupType; 13 | fn backing_storage(&self) -> Vec; 14 | } 15 | -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/verdana11.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(verdana11) 3 | 4 | #ifndef __VERDANA11__ 5 | #define __VERDANA11__ 6 | 7 | extern const TFont verdana11Font; 8 | 9 | #define verdana11GlyphsLen 3072 10 | extern const unsigned int verdana11Glyphs[768]; 11 | 12 | #define verdana11WidthsLen 96 13 | extern const unsigned char verdana11Widths[96]; 14 | 15 | #endif // __VERDANA11__ 16 | 17 | //}}BLOCK(verdana11) 18 | -------------------------------------------------------------------------------- /external/tonc/code/ext/oacombo/oacombo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /gba-core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gba-core" 3 | version = "0.1.0" 4 | edition = "2024" 5 | build = "build.rs" 6 | 7 | [dependencies] 8 | bitflags = "2.6.0" 9 | bitmatch = "0.1.1" 10 | goblin = "0.9.2" 11 | rhai = { version = "1.17.1", features = ["sync"] } 12 | thiserror = "2.0.12" 13 | phf = { version = "0.12.1", features = ["macros"] } 14 | crc32fast = "1.4.2" 15 | tracing = "0.1.41" 16 | 17 | [build-dependencies] 18 | csv = "1.3.1" 19 | -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/mssans9.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(mssans9) 3 | 4 | #ifndef __MSSANS9__ 5 | #define __MSSANS9__ 6 | 7 | // MicroSoft Sans Serif 9, 32-255, 1bpp 8 | 9 | extern const TFont mssans9Font; 10 | 11 | #define mssans9GlyphsLen 3584 12 | extern const unsigned int mssans9Glyphs[896]; 13 | 14 | #define mssans9WidthsLen 224 15 | extern const unsigned char mssans9Widths[224]; 16 | 17 | #endif // __MSSANS9__ 18 | 19 | //}}BLOCK(mssans9) 20 | -------------------------------------------------------------------------------- /external/tonc/code/basic/second/second.c: -------------------------------------------------------------------------------- 1 | // 2 | // second.c 3 | // Cleaner version of 'first.c' 4 | // 5 | // (20060211 - 20060922, cearn) 6 | 7 | #include "toolbox.h" 8 | 9 | int main() 10 | { 11 | REG_DISPCNT= DCNT_MODE3 | DCNT_BG2; 12 | 13 | m3_plot( 120, 80, RGB15(31, 0, 0) ); // or CLR_RED 14 | m3_plot( 136, 80, RGB15( 0,31, 0) ); // or CLR_LIME 15 | m3_plot( 120, 96, RGB15( 0, 0,31) ); // or CLR_BLUE 16 | 17 | while(1); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/fonts/cyber16.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(cyber16) 3 | 4 | #ifndef __CYBER16__ 5 | #define __CYBER16__ 6 | 7 | // Cybernator font, 8x16@4. Missing ascii have been added. 8 | 9 | extern const TFont cyber16Font; 10 | 11 | #define cyber16GlyphsLen 6144 12 | extern const unsigned int cyber16Glyphs[1536]; 13 | 14 | #define cyber16PalLen 32 15 | extern const unsigned short cyber16Pal[32]; 16 | 17 | #endif // __CYBER16__ 18 | 19 | //}}BLOCK(cyber16) 20 | -------------------------------------------------------------------------------- /external/tonc/code/basic/first/first.mak: -------------------------------------------------------------------------------- 1 | # 2 | # first.mak 3 | # 4 | # a minimal makefile (and I do mean minimal, look to the others 5 | # for real-life use) 6 | 7 | PATH := $(DEVKITARM)/bin:$(PATH) 8 | 9 | first.gba : first.c 10 | arm-none-eabi-gcc -mthumb -mthumb-interwork -c first.c 11 | arm-none-eabi-gcc -specs=gba.specs -mthumb -mthumb-interwork first.o -o first.elf 12 | arm-none-eabi-objcopy -v -O binary first.elf first.gba 13 | gbafix first.gba 14 | 15 | #EOF 16 | -------------------------------------------------------------------------------- /debugger/src/dbg/widgets/mod.rs: -------------------------------------------------------------------------------- 1 | use egui::Color32; 2 | 3 | pub mod cpu; 4 | pub mod disasm; 5 | pub mod memory; 6 | pub mod ppu; 7 | 8 | const DIRTY_COLOR: Color32 = Color32::from_rgba_premultiplied(250, 160, 160, 255); 9 | const PC_COLOR: Color32 = Color32::from_rgba_premultiplied(193, 225, 193, 255); 10 | const R15_COLOR: Color32 = Color32::from_rgba_premultiplied(195, 177, 225, 255); 11 | const TRANSPARENT_COLOR: Color32 = Color32::from_rgba_premultiplied(255, 192, 203, 255); 12 | -------------------------------------------------------------------------------- /external/tonc/code/basic/first/first.bat: -------------------------------------------------------------------------------- 1 | REM batch-file for first.gba 2 | REM Note: you have to set the paths correctly first to make it work 3 | REM Using makefiles is recommended. 4 | 5 | PATH= e:\dev\msys\1.0\bin;e:\dev\devkitPro\devkitArm\bin; 6 | 7 | arm-eabi-gcc -thum -mthumb-interworkb -c first.c 8 | arm-eabi-gcc -mthumb -specs=gba_mb.specs -mthumb-interwork first.o -o first.elf 9 | arm-eabi-objcopy -O binary first.elf first.gba 10 | gbafix first.gba 11 | 12 | pause 13 | 14 | -------------------------------------------------------------------------------- /external/tonc/code/ext/tmr_demo/berk.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(berk) 3 | 4 | #ifndef __BERK__ 5 | #define __BERK__ 6 | 7 | // Berka! Berka! Berka! 8 | // berk.gif font from headsipn's collection. 9 | // 24x40@4, tiled, with palette 10 | 11 | extern const TFont berkFont; 12 | 13 | #define berkGlyphsLen 5280 14 | extern const unsigned int berkGlyphs[1320]; 15 | 16 | #define berkPalLen 32 17 | extern const unsigned short berkPal[32]; 18 | 19 | #endif // __BERK__ 20 | 21 | //}}BLOCK(berk) 22 | -------------------------------------------------------------------------------- /external/tonc/code/basic/brin_demo/toolbox.c: -------------------------------------------------------------------------------- 1 | // 2 | // toolbox.c 3 | // 4 | // Tools source for sbb_reg 5 | // 6 | // (20060922-20060922, cearn) 7 | // 8 | // === NOTES === 9 | // * This is a _small_ set of typedefs, #defines and inlines that can 10 | // be found in tonclib, and might not represent the 11 | // final forms. 12 | 13 | #include "toolbox.h" 14 | 15 | // === (tonc_core.c) ================================================== 16 | 17 | u16 __key_curr= 0, __key_prev= 0; 18 | -------------------------------------------------------------------------------- /external/tonc/code/basic/sbb_reg/toolbox.c: -------------------------------------------------------------------------------- 1 | // 2 | // toolbox.c 3 | // 4 | // Tools source for sbb_reg 5 | // 6 | // (20060922-20060922, cearn) 7 | // 8 | // === NOTES === 9 | // * This is a _small_ set of typedefs, #defines and inlines that can 10 | // be found in tonclib, and might not represent the 11 | // final forms. 12 | 13 | #include "toolbox.h" 14 | 15 | // === (tonc_core.c) ================================================== 16 | 17 | u16 __key_curr= 0, __key_prev= 0; 18 | 19 | -------------------------------------------------------------------------------- /external/tonc/code/adv/txt_bm/txt_bm.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /external/tonc/code/lab/octtest/octtest.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /external/tonc/code/adv/txt_obj/txt_obj.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /external/tonc/code/adv/txt_se1/txt_se1.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /external/tonc/code/adv/txt_se2/txt_se2.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/basic/obj_demo/obj_demo.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/lab/prio_demo/prio_demo.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /scripts/scooby_fix_eeprom.rhai: -------------------------------------------------------------------------------- 1 | fn spoof_flash_chip_id() { 2 | let opcode = emu.read_u32(addr); 3 | let instr = disasm(opcode, emu.is_thumb()); 4 | println(`Spoofing flash chip ID for instruction: ${instr}`); 5 | let operand = instr.sub_string(instr.index_of(" ") + 1, 2); 6 | emu.write_register(operand, 1); 7 | } 8 | 9 | fn setup() { 10 | let breakpoints = #{ 11 | // memory rw breakpoints 12 | "0x0d000000": "spoof_flash_chip_id" 13 | }; 14 | breakpoints 15 | } -------------------------------------------------------------------------------- /external/tonc/code/basic/key_demo/toolbox.c: -------------------------------------------------------------------------------- 1 | // 2 | // toolbox.c 3 | // 4 | // Tools source for key_demo 5 | // 6 | // (20060922-20060922, cearn) 7 | // 8 | // === NOTES === 9 | // * This is a _small_ set of typedefs, #defines and inlines that can 10 | // be found in tonclib, and might not represent the 11 | // final forms. 12 | 13 | #include "toolbox.h" 14 | 15 | // === (tonc_core.c) ================================================== 16 | 17 | u16 __key_curr= 0, __key_prev= 0; 18 | COLOR *vid_page= vid_mem_back; 19 | -------------------------------------------------------------------------------- /external/tonc/code/basic/first/first.c: -------------------------------------------------------------------------------- 1 | // 2 | // first.c 3 | // "Hello World" equivalent 4 | // 5 | // (20030901 - 20060211, cearn) 6 | // === NOTES === 7 | // * You are not expected to understand this. Check second.c for 8 | // a more proper version. 9 | 10 | 11 | int main() 12 | { 13 | *(unsigned int*)0x04000000= 0x0403; 14 | 15 | ((unsigned short*)0x06000000)[120+80*240]= 0x001F; 16 | ((unsigned short*)0x06000000)[136+80*240]= 0x03E0; 17 | ((unsigned short*)0x06000000)[120+96*240]= 0x7C00; 18 | 19 | while(1); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /external/tonc/code/basic/hello/hello.c: -------------------------------------------------------------------------------- 1 | // 2 | //! \file hello_demo.c 3 | //! Screen-entry text demo 4 | //! \date 20060228 - 20080416 5 | //! \author cearn 6 | // 7 | // === NOTES === 8 | 9 | #include 10 | #include 11 | 12 | int main() 13 | { 14 | REG_DISPCNT= DCNT_MODE0 | DCNT_BG0; 15 | 16 | // Init BG 0 for text on screen entries. 17 | tte_init_se_default(0, BG_CBB(0)|BG_SBB(31)); 18 | 19 | tte_write("#{P:72,64}"); // Goto (72, 64). 20 | tte_write("Hello World!"); // Print "Hello world!" 21 | 22 | while(1); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /external/tonc/code/lab/bigmap/bigmap.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rom-db-ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rom-db-ui", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev --turbopack", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "react": "^19.0.0", 13 | "react-dom": "^19.0.0", 14 | "next": "15.3.2" 15 | }, 16 | "devDependencies": { 17 | "typescript": "^5", 18 | "@types/node": "^20", 19 | "@types/react": "^19", 20 | "@types/react-dom": "^19", 21 | "@tailwindcss/postcss": "^4", 22 | "tailwindcss": "^4" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /external/clean_screenshots.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BASE_DIR="$1" 4 | 5 | process_subdir() { 6 | subdir="$1" 7 | echo "Processing: $subdir" 8 | find "$subdir" -type f -iname '*.png' | while read -r file; do 9 | mean=$(convert "$file" -format "%[mean]" info:) 10 | if [[ "$mean" == "0" ]] || [[ "$mean" == "65535" ]]; then 11 | echo "Removing black/white image: $file" 12 | rm -f "$file" 13 | fi 14 | done 15 | fdupes -rdN "$subdir" 16 | } 17 | 18 | export -f process_subdir 19 | 20 | find "$BASE_DIR" -mindepth 1 -maxdepth 1 -type d | parallel -j40 process_subdir {} 21 | -------------------------------------------------------------------------------- /external/tonc/code/lab/template/template.pnproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /external/tonc/code/basic/bm_modes/modes.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // modes, 240x160@16, 4 | // + bitmap not compressed 5 | // Total size: 76800 = 76800 6 | // 7 | // Time-stamp: 2005-12-24, 18:13:22 8 | // Exported by Cearn's Usenti v1.7.1 9 | // (comments, kudos, flames to "daytshen@hotmail.com") 10 | // 11 | //====================================================================== 12 | 13 | #ifndef __MODES__ 14 | #define __MODES__ 15 | 16 | #define modesBitmapLen 76800 17 | extern const unsigned int modesBitmap[19200]; 18 | 19 | #define modesPalLen 32 20 | extern const unsigned int modesPal[8]; 21 | 22 | #endif // __MODES__ 23 | 24 | -------------------------------------------------------------------------------- /rom-db-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | .pnpm-debug.log* 32 | 33 | # env files (can opt-in for committing if needed) 34 | .env* 35 | 36 | # vercel 37 | .vercel 38 | 39 | # typescript 40 | *.tsbuildinfo 41 | next-env.d.ts 42 | 43 | public/ -------------------------------------------------------------------------------- /external/tonc/code/lab/prio_demo/prio_gfx.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // ball, 16x16@4, 4 | // + palette 128 entries, not compressed 5 | // + 4 tiles not compressed 6 | // Total size: 256 + 128 = 384 7 | // 8 | // Time-stamp: 2006-04-09, 19:33:17 9 | // Exported by Cearn's Usenti v1.7.4 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __BALL__ 15 | #define __BALL__ 16 | 17 | #define ballPalLen 256 18 | extern const unsigned int ballPal[64]; 19 | 20 | #define ballTilesLen 128 21 | extern const unsigned int ballTiles[32]; 22 | 23 | #endif // __BALL__ 24 | 25 | -------------------------------------------------------------------------------- /external/tonc/code/basic/first/first_msys.bat: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # you can also try running in an MSYS box, which is 4 | # better than a DOS box, but setting the path is a little different 5 | # use 6 | # PATH=[path1:path2]. 7 | # separate the list by colons ':' 8 | # and _no_ spaces around the '='!! 9 | # 10 | # Comment with '#', obviously, and pasting uses the middle-mouse button. 11 | # an MSYS box also allows scrolling and moving around by arrows 12 | # 13 | 14 | PATH := $(DEVKITARM)/bin:$(PATH) 15 | 16 | arm-elf-gcc -mthumb -mthumb-interwork -c first.c 17 | arm-elf-gcc -specs=gba_mb.specs -mthumb -mthumb-interwork first.o -o first.elf 18 | arm-elf-objcopy -O binary first.elf first.gba 19 | gbafix first.gba 20 | 21 | 22 | -------------------------------------------------------------------------------- /rom-db-ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /external/tonc/code/adv/txt_se1/border.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // border, 24x48@4, 4 | // + palette 16 entries, not compressed 5 | // + 18 tiles not compressed 6 | // Total size: 32 + 576 = 608 7 | // 8 | // Time-stamp: 2005-12-07, 19:34:09 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __BORDER__ 15 | #define __BORDER__ 16 | 17 | #define borderPalLen 32 18 | extern const unsigned int borderPal[8]; 19 | 20 | #define borderTilesLen 576 21 | extern const unsigned int borderTiles[144]; 22 | 23 | #endif // __BORDER__ 24 | 25 | -------------------------------------------------------------------------------- /external/tonc/code/ext/win_demo/rocket.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // rocket, 16x16@4, 4 | // + palette 16 entries, not compressed 5 | // + 4 tiles not compressed 6 | // Total size: 32 + 128 = 160 7 | // 8 | // Time-stamp: 2006-01-04, 18:14:01 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __ROCKET__ 15 | #define __ROCKET__ 16 | 17 | #define rocketPalLen 32 18 | extern const unsigned int rocketPal[8]; 19 | 20 | #define rocketTilesLen 128 21 | extern const unsigned int rocketTiles[32]; 22 | 23 | #endif // __ROCKET__ 24 | 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/gba-tests"] 2 | path = external/gba-tests 3 | url = https://github.com/jsmolka/gba-tests 4 | [submodule "external/gba-div-test"] 5 | path = external/gba-div-test 6 | url = https://github.com/ioncodes/gba-div-test 7 | [submodule "external/gba_tests"] 8 | path = external/gba_tests 9 | url = https://github.com/destoer/gba_tests 10 | [submodule "external/gba-psr-test"] 11 | path = external/gba-psr-test 12 | url = https://github.com/ioncodes/gba-psr-test 13 | [submodule "external/armwrestler-gba-fixed"] 14 | path = external/armwrestler-gba-fixed 15 | url = https://github.com/destoer/armwrestler-gba-fixed 16 | [submodule "external/FuzzARM"] 17 | path = external/FuzzARM 18 | url = https://github.com/DenSinH/FuzzARM 19 | -------------------------------------------------------------------------------- /external/tonc/code/adv/txt_se2/gba_pic.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // gba_pic, 240x160@8, 4 | // + palette 16 entries, not compressed 5 | // + bitmap not compressed 6 | // Total size: 32 + 38400 = 38432 7 | // 8 | // Time-stamp: 2005-12-24, 14:31:24 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __GBA_PIC__ 15 | #define __GBA_PIC__ 16 | 17 | #define gba_picPalLen 32 18 | extern const unsigned int gba_picPal[8]; 19 | 20 | #define gba_picBitmapLen 38400 21 | extern const unsigned int gba_picBitmap[9600]; 22 | 23 | #endif // __GBA_PIC__ 24 | 25 | -------------------------------------------------------------------------------- /external/tonc/code/basic/key_demo/gba_pic.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // gba_pic, 240x160@8, 4 | // + palette 16 entries, not compressed 5 | // + bitmap not compressed 6 | // Total size: 32 + 38400 = 38432 7 | // 8 | // Time-stamp: 2005-12-24, 14:31:24 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __GBA_PIC__ 15 | #define __GBA_PIC__ 16 | 17 | #define gba_picPalLen 32 18 | extern const unsigned int gba_picPal[8]; 19 | 20 | #define gba_picBitmapLen 38400 21 | extern const unsigned int gba_picBitmap[9600]; 22 | 23 | #endif // __GBA_PIC__ 24 | 25 | -------------------------------------------------------------------------------- /external/tonc/code/ext/oacombo/oac_gfx.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // oac_gfx, 64x32@4, 4 | // + palette 16 entries, not compressed 5 | // + 32 tiles 4x4 metatiles not compressed 6 | // Total size: 32 + 1024 = 1056 7 | // 8 | // Time-stamp: 2006-04-20, 20:30:22 9 | // Exported by Cearn's Usenti v1.7.4 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __OAC_GFX__ 15 | #define __OAC_GFX__ 16 | 17 | #define oac_gfxPalLen 32 18 | extern const unsigned int oac_gfxPal[8]; 19 | 20 | #define oac_gfxTilesLen 1024 21 | extern const unsigned int oac_gfxTiles[256]; 22 | 23 | #endif // __OAC_GFX__ 24 | 25 | -------------------------------------------------------------------------------- /external/tonc/code/adv/tte_demo/tte_demo.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rom-db-ui/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from "next"; 2 | import { Geist } from "next/font/google"; 3 | import "./globals.css"; 4 | 5 | const geistSans = Geist({ 6 | variable: "--font-geist-sans", 7 | subsets: ["latin"], 8 | }); 9 | 10 | export const metadata: Metadata = { 11 | title: "ayyboy advance screenshots", 12 | description: "A collection of screenshots taken from ayyboy advance", 13 | }; 14 | 15 | export default function RootLayout({ 16 | children, 17 | }: Readonly<{ 18 | children: React.ReactNode; 19 | }>) { 20 | return ( 21 | 22 | 23 |
{children}
24 | 25 | 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /debugger/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ayydbg" 3 | version = "0.1.0" 4 | edition = "2024" 5 | default-run = "ayydbg" 6 | 7 | [dependencies] 8 | gba-core = { path = "../gba-core" } 9 | egui = "0.31.1" 10 | egui-phosphor = "0.9.0" 11 | egui_extras = "0.31.1" 12 | eframe = "0.31.1" 13 | crossbeam-channel = "0.5.13" 14 | lazy_static = "1.5.0" 15 | clap = { version = "4.5.38", features = ["derive"] } 16 | zip = { version = "4.0.0", default-features = false, features = ["deflate"] } 17 | image = { version = "0.25.6", default-features = false, features = ["png"] } 18 | chrono = "0.4.41" 19 | egui-toast = "0.17.0" 20 | shadow-rs = { version = "1.2.0", default-features = false } 21 | tracing = "0.1.41" 22 | tracing-subscriber = "0.3.19" 23 | 24 | [build-dependencies] 25 | shadow-rs = "1.2.0" 26 | -------------------------------------------------------------------------------- /external/tonc/code/basic/bm_modes/toolbox.c: -------------------------------------------------------------------------------- 1 | // 2 | // toolbox.c 3 | // 4 | // Tools source for bm_modes 5 | // 6 | // (20060922-20060922, cearn) 7 | // 8 | // === NOTES === 9 | // * This is a _small_ set of typedefs, #defines and inlines that can 10 | // be found in tonclib, and might not represent the 11 | // final forms. 12 | 13 | #include "toolbox.h" 14 | 15 | // === (tonc_core.c) ================================================== 16 | 17 | u16 __key_curr= 0, __key_prev= 0; 18 | COLOR *vid_page= vid_mem_back; 19 | 20 | 21 | // === (tonc_bitmap.c) ================================================ 22 | 23 | COLOR *vid_flip() 24 | { 25 | vid_page= (COLOR*)((u32)vid_page ^ VRAM_PAGE_SIZE); 26 | REG_DISPCNT ^= DCNT_PAGE; // update control register 27 | 28 | return vid_page; 29 | } 30 | -------------------------------------------------------------------------------- /external/tonc/code/basic/pageflip/toolbox.c: -------------------------------------------------------------------------------- 1 | // 2 | // toolbox.c 3 | // 4 | // Tools source for pageflip 5 | // 6 | // (20060922-20060922, cearn) 7 | // 8 | // === NOTES === 9 | // * This is a _small_ set of typedefs, #defines and inlines that can 10 | // be found in tonclib, and might not represent the 11 | // final forms. 12 | 13 | #include "toolbox.h" 14 | 15 | // === (tonc_core.c) ================================================== 16 | 17 | u16 __key_curr= 0, __key_prev= 0; 18 | COLOR *vid_page= vid_mem_back; 19 | 20 | 21 | // === (tonc_bitmap.c) ================================================ 22 | 23 | COLOR *vid_flip() 24 | { 25 | vid_page= (COLOR*)((u32)vid_page ^ VRAM_PAGE_SIZE); 26 | REG_DISPCNT ^= DCNT_PAGE; // update control register 27 | 28 | return vid_page; 29 | } 30 | -------------------------------------------------------------------------------- /external/tonc/code/lab/prio_demo/prio.iwram.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | 5 | //! Sort indices via shell sort 6 | /*! \param keys Array sort keys 7 | * \param ids Array of indices. After completion keys[ids[ii]] 8 | * will be sorted in ascending order. 9 | * \param count Number of entries. 10 | */ 11 | IWRAM_CODE void id_sort_shell(int keys[], u8 ids[], int count) 12 | { 13 | u32 ii, inc; 14 | 15 | // find initial 'inc' in sequence x[i+1] = 3*x[i]+1 ; x[1]=1 16 | for(inc=1; inc<=count; inc++) 17 | inc *= 3; 18 | // actual sort 19 | do 20 | { 21 | inc /= 3; 22 | for(ii=inc; ii=inc && keys[ids[jj-inc]]>key0; jj -= inc) 27 | ids[jj]= ids[jj-inc]; 28 | ids[jj]= id0; 29 | } 30 | } while(inc > 1); 31 | } 32 | -------------------------------------------------------------------------------- /external/tonc/code/lab/bigmap/link_gfx.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(link_gfx) 3 | 4 | //====================================================================== 5 | // 6 | // link_gfx, 128x48@4, 7 | // + palette 16 entries, not compressed 8 | // + 96 tiles 2x2 metatiles not compressed 9 | // Total size: 32 + 3072 = 3104 10 | // 11 | // Time-stamp: 2007-02-16, 19:39:31 12 | // Exported by Cearn's Usenti v1.7.7 13 | // (comments, kudos, flames to "daytshen@hotmail.com") 14 | // 15 | //====================================================================== 16 | 17 | #ifndef __LINK_GFX__ 18 | #define __LINK_GFX__ 19 | 20 | #define link_gfxPalLen 32 21 | extern const unsigned int link_gfxPal[8]; 22 | 23 | #define link_gfxTilesLen 3072 24 | extern const unsigned int link_gfxTiles[768]; 25 | 26 | #endif // __LINK_GFX__ 27 | 28 | //}}BLOCK(link_gfx) 29 | -------------------------------------------------------------------------------- /external/tonc/code/basic/bm_modes/bm_modes.c: -------------------------------------------------------------------------------- 1 | // 2 | // bm_modes.c 3 | // Combined demo of modes 3, 4 and 5 4 | // 5 | // (20031002 - 20060922, cearn) 6 | 7 | #include 8 | #include "toolbox.h" 9 | #include "modes.h" 10 | 11 | int main() 12 | { 13 | int mode= 3; 14 | REG_DISPCNT= mode | DCNT_BG2; 15 | 16 | // Copy the data and palette to the right 17 | // addresses 18 | memcpy(vid_mem, modesBitmap, modesBitmapLen); 19 | memcpy(pal_bg_mem, modesPal, modesPalLen); 20 | 21 | while(1) 22 | { 23 | // Wait till VBlank before doing anything 24 | vid_vsync(); 25 | 26 | // Check keys for mode change 27 | key_poll(); 28 | if(key_hit(KEY_LEFT) && mode>3) 29 | mode--; 30 | else if(key_hit(KEY_RIGHT) && mode<5) 31 | mode++; 32 | 33 | // Change the mode 34 | REG_DISPCNT= mode | DCNT_BG2; 35 | } 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tonc_video.c: -------------------------------------------------------------------------------- 1 | // 2 | // Basic video functionality 3 | // 4 | //! \file tonc_video.c 5 | //! \author J Vijn 6 | //! \date 20060604 - 20070805 7 | // 8 | // === NOTES === 9 | 10 | #include "tonc_memmap.h" 11 | #include "tonc_core.h" 12 | #include "tonc_video.h" 13 | 14 | 15 | // -------------------------------------------------------------------- 16 | // FUNCTIONS 17 | // -------------------------------------------------------------------- 18 | 19 | 20 | //! Flip the display page. 21 | /*! Toggles the display page in REG_DISPCNT and sets \a vid_page 22 | to point to the back buffer. 23 | \return Current back buffer pointer. 24 | */ 25 | COLOR *vid_flip(void) 26 | { 27 | vid_page= (COLOR*)((u32)vid_page ^ VRAM_PAGE_SIZE); 28 | REG_DISPCNT ^= DCNT_PAGE; // update control register 29 | 30 | return vid_page; 31 | } 32 | 33 | // EOF 34 | -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_demo/source/m7_demo.h: -------------------------------------------------------------------------------- 1 | // 2 | // m7_isrs.c 3 | // Separate file for HBL interrupts because apparently it screws up 4 | // on hardware now. 5 | 6 | #include 7 | 8 | #ifndef __M7_DEMO__ 9 | #define __M7_DEMO__ 10 | 11 | // === CONSTANTS & MACROS ============================================= 12 | 13 | #define M7_D 160 14 | 15 | enum eMode7Type 16 | { M7_BLOCK=0, M7_SAW, M7_SMOOTH}; 17 | 18 | 19 | // === GLOBALS ======================================================== 20 | 21 | extern VECTOR cam_pos; 22 | extern u16 cam_phi; 23 | extern FIXED g_cosf, g_sinf; 24 | extern int g_state; 25 | 26 | // === PROTOTYPES ===================================================== 27 | 28 | void set_mode7_type(int type); 29 | 30 | IWRAM_CODE void m7_hbl_a(); 31 | IWRAM_CODE void m7_hbl_b(); 32 | IWRAM_CODE void m7_hbl_c(); 33 | 34 | #endif // __M7_DEMO__ 35 | -------------------------------------------------------------------------------- /external/tonc/code/lab/template/source/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | // Init interrupts and VBlank irq. 8 | irq_init(NULL); 9 | irq_add(II_VBLANK, NULL); 10 | 11 | // Video mode 0, enable bg 0. 12 | REG_DISPCNT= DCNT_MODE0 | DCNT_BG0; 13 | 14 | // Init 4bpp vwf text on bg 0. 15 | tte_init_chr4c(0, // BG 0 16 | BG_CBB(0)|BG_SBB(31), // Charblock 0; screenblock 31 17 | 0xF000, // Screen-entry offset 18 | bytes2word(1,2,0,0), // Color attributes. 19 | CLR_YELLOW, // Yellow text 20 | &verdana9Font, // Verdana 9 font 21 | NULL // Use default chr4 renderer 22 | ); 23 | 24 | // Initialize use of stdio. 25 | tte_init_con(); 26 | 27 | // Printf something at 96,72 28 | tte_printf("#{P:96,72}Hello World!"); 29 | 30 | while(1) 31 | { 32 | VBlankIntrWait(); 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /external/tonc/code/lab/octtest/octants.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // octants, 256x256@8, 4 | // + palette 16 entries, not compressed 5 | // + 172 tiles (t reduced) lz77 compressed 6 | // + affine map, lz77 compressed, 32x32 7 | // Total size: 32 + 1940 + 476 = 2448 8 | // 9 | // Time-stamp: 2006-09-26, 19:52:57 10 | // Exported by Cearn's Usenti v1.7.6 11 | // (comments, kudos, flames to "daytshen@hotmail.com") 12 | // 13 | //====================================================================== 14 | 15 | #ifndef __OCTANTS__ 16 | #define __OCTANTS__ 17 | 18 | #define octantsPalLen 32 19 | extern const unsigned int octantsPal[8]; 20 | 21 | #define octantsTilesLen 1940 22 | extern const unsigned int octantsTiles[485]; 23 | 24 | #define octantsMapLen 476 25 | extern const unsigned int octantsMap[119]; 26 | 27 | #endif // __OCTANTS__ 28 | 29 | -------------------------------------------------------------------------------- /external/tonc/code/lab/prio_demo/prio_bg.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // cage, 256x512@8, 4 | // + palette 128 entries, not compressed 5 | // + 218 tiles (t|f reduced) not compressed 6 | // + regular map (flat), not compressed, 32x64 7 | // Total size: 256 + 13952 + 4096 = 18304 8 | // 9 | // Time-stamp: 2006-04-17, 00:27:04 10 | // Exported by Cearn's Usenti v1.7.4 11 | // (comments, kudos, flames to "daytshen@hotmail.com") 12 | // 13 | //====================================================================== 14 | 15 | #ifndef __CAGE__ 16 | #define __CAGE__ 17 | 18 | #define cagePalLen 256 19 | extern const unsigned short cagePal[128]; 20 | 21 | #define cageTilesLen 13952 22 | extern const unsigned short cageTiles[6976]; 23 | 24 | #define cageMapLen 4096 25 | extern const unsigned short cageMap[2048]; 26 | 27 | #endif // __CAGE__ 28 | 29 | -------------------------------------------------------------------------------- /external/tonc/code/ext/dma_demo/brin.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(brin) 3 | 4 | //====================================================================== 5 | // 6 | // brin, 512x256@4, 7 | // + palette 256 entries, not compressed 8 | // + 31 tiles (t|f|p reduced) not compressed 9 | // + regular map (in SBBs), not compressed, 64x32 10 | // Total size: 512 + 992 + 4096 = 5600 11 | // 12 | // Time-stamp: 2007-02-16, 14:23:41 13 | // Exported by Cearn's Usenti v1.7.7 14 | // (comments, kudos, flames to "daytshen@hotmail.com") 15 | // 16 | //====================================================================== 17 | 18 | #ifndef __BRIN__ 19 | #define __BRIN__ 20 | 21 | #define brinPalLen 512 22 | extern const unsigned short brinPal[256]; 23 | 24 | #define brinTilesLen 992 25 | extern const unsigned short brinTiles[496]; 26 | 27 | #define brinMapLen 4096 28 | extern const unsigned short brinMap[2048]; 29 | 30 | #endif // __BRIN__ 31 | 32 | //}}BLOCK(brin) 33 | -------------------------------------------------------------------------------- /external/tonc/code/basic/brin_demo/brin.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(brin) 3 | 4 | //====================================================================== 5 | // 6 | // brin, 512x256@4, 7 | // + palette 256 entries, not compressed 8 | // + 31 tiles (t|f|p reduced) not compressed 9 | // + regular map (in SBBs), not compressed, 64x32 10 | // Total size: 512 + 992 + 4096 = 5600 11 | // 12 | // Time-stamp: 2007-02-16, 14:23:41 13 | // Exported by Cearn's Usenti v1.7.7 14 | // (comments, kudos, flames to "daytshen@hotmail.com") 15 | // 16 | //====================================================================== 17 | 18 | #ifndef __BRIN__ 19 | #define __BRIN__ 20 | 21 | #define brinPalLen 512 22 | extern const unsigned short brinPal[256]; 23 | 24 | #define brinTilesLen 992 25 | extern const unsigned short brinTiles[496]; 26 | 27 | #define brinMapLen 4096 28 | extern const unsigned short brinMap[2048]; 29 | 30 | #endif // __BRIN__ 31 | 32 | //}}BLOCK(brin) 33 | -------------------------------------------------------------------------------- /external/tonc/code/lab/bigmap/kakariko.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(kakariko) 3 | 4 | //====================================================================== 5 | // 6 | // kakariko, 1024x1024@4, 7 | // + palette 256 entries, not compressed 8 | // + 319 tiles (t|f|p reduced) lz77 compressed 9 | // + regular map (flat), not compressed, 128x128 10 | // Total size: 512 + 5936 + 32768 = 39216 11 | // 12 | // Time-stamp: 2007-02-16, 23:41:18 13 | // Exported by Cearn's Usenti v1.7.7 14 | // (comments, kudos, flames to "daytshen@hotmail.com") 15 | // 16 | //====================================================================== 17 | 18 | #ifndef __KAKARIKO__ 19 | #define __KAKARIKO__ 20 | 21 | #define kakarikoPalLen 512 22 | extern const unsigned short kakarikoPal[256]; 23 | 24 | #define kakarikoTilesLen 5936 25 | extern const unsigned short kakarikoTiles[2968]; 26 | 27 | #define kakarikoMapLen 32768 28 | extern const unsigned short kakarikoMap[16384]; 29 | 30 | #endif // __KAKARIKO__ 31 | 32 | //}}BLOCK(kakariko) 33 | -------------------------------------------------------------------------------- /gba-core/src/audio/apu.rs: -------------------------------------------------------------------------------- 1 | use crate::memory::device::Addressable; 2 | 3 | pub struct Apu { 4 | io: Box<[u8; (0x400008E - 0x4000080) + 1]>, 5 | } 6 | 7 | impl Apu { 8 | pub fn new() -> Apu { 9 | let io = Box::<[u8; (0x400008E - 0x4000080) + 1]>::new_zeroed(); 10 | 11 | Apu { 12 | io: unsafe { io.assume_init() }, 13 | } 14 | } 15 | } 16 | 17 | impl Addressable for Apu { 18 | fn read(&self, addr: u32) -> u8 { 19 | match addr { 20 | // SOUNDBIAS register 21 | 0x04000088 => 0x00, 22 | 0x04000089 => 0x02, 23 | // rest of the registers 24 | 0x4000080..=0x400008E => self.io[(addr - 0x4000080) as usize], 25 | _ => unreachable!(), 26 | } 27 | } 28 | 29 | fn write(&mut self, addr: u32, value: u8) { 30 | match addr { 31 | 0x4000080..=0x400008E => self.io[(addr - 0x4000080) as usize] = value, 32 | _ => unreachable!(), 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /external/tonc/code/basic/brin_demo/brin_demo.c: -------------------------------------------------------------------------------- 1 | // 2 | // brin_demo.c 3 | // Essential tilemap loading: the start of brinstar from metroid 1 4 | // 5 | // (20060221 - 20070216, cearn) 6 | 7 | #include 8 | 9 | #include "toolbox.h" 10 | #include "input.h" 11 | #include "brin.h" 12 | 13 | int main() 14 | { 15 | // Load palette 16 | memcpy(pal_bg_mem, brinPal, brinPalLen); 17 | // Load tiles into CBB 0 18 | memcpy(&tile_mem[0][0], brinTiles, brinTilesLen); 19 | // Load map into SBB 30 20 | memcpy(&se_mem[30][0], brinMap, brinMapLen); 21 | 22 | // set up BG0 for a 4bpp 64x32t map, using 23 | // using charblock 0 and screenblock 31 24 | REG_BG0CNT= BG_CBB(0) | BG_SBB(30) | BG_4BPP | BG_REG_64x32; 25 | REG_DISPCNT= DCNT_MODE0 | DCNT_BG0; 26 | 27 | // Scroll around some 28 | int x= 192, y= 64; 29 | while(1) 30 | { 31 | vid_vsync(); 32 | key_poll(); 33 | 34 | x += key_tri_horz(); 35 | y += key_tri_vert(); 36 | 37 | REG_BG0HOFS= x; 38 | REG_BG0VOFS= y; 39 | } 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /external/tonc/code/ext/win_demo/rocket.c: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // rocket, 16x16@4, 4 | // + palette 16 entries, not compressed 5 | // + 4 tiles not compressed 6 | // Total size: 32 + 128 = 160 7 | // 8 | // Time-stamp: 2006-01-04, 18:14:01 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | const unsigned int rocketPal[8]= 15 | { 16 | 0x0000673F,0x2D081865,0x5A7341AD,0x48FB7FFF,0x02DF021B,0x00000000,0x00000000,0x00000000, 17 | }; 18 | 19 | const unsigned int rocketTiles[32]= 20 | { 21 | 0x55200000,0x22552000,0x00225200,0x70002500,0x67002520,0x77000250,0x98000050,0x64000050, 22 | 0x00000244,0x00024422,0x00240000,0x00400007,0x02400077,0x04200077,0x04000088,0x04000042, 23 | 0x30000050,0x63000050,0x63000050,0x30060050,0x64350050,0x64340050,0x33000040,0x55444330, 24 | 0x04000003,0x04000034,0x04000034,0x04005003,0x04004332,0x04004432,0x03000033,0x03344455, 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /debugger/src/event.rs: -------------------------------------------------------------------------------- 1 | use gba_core::input::registers::KeyInput; 2 | use gba_core::video::ppu::Sprite; 3 | use gba_core::video::registers::InternalScreenSize; 4 | use gba_core::video::{Frame, Pixel}; 5 | 6 | use crate::dbg::widgets::ppu::PpuRegisters; 7 | 8 | use super::dbg::widgets::cpu::Cpu; 9 | use super::dbg::widgets::disasm::DecodedInstruction; 10 | 11 | #[derive(Debug)] 12 | pub enum RequestEvent { 13 | UpdateMemory, 14 | UpdateCpu, 15 | UpdatePpu, 16 | UpdateDisassembly(Option, u32), 17 | Break, 18 | Run, 19 | Step, 20 | AddBreakpoint(u32), 21 | RemoveBreakpoint(u32), 22 | UpdateKeyState(Vec<(KeyInput, bool)>), 23 | } 24 | 25 | pub enum ResponseEvent { 26 | Memory(Box<[u8; 0x0FFFFFFF + 1]>), 27 | Cpu(Cpu), 28 | Disassembly(u32, u32, Vec), 29 | Ppu( 30 | Vec, 31 | (usize, Vec), 32 | [(InternalScreenSize, Vec); 4], 33 | Vec, 34 | PpuRegisters, 35 | Vec, 36 | ), // TODO: BG Mode 3,4,5 each frame 0 and 1 37 | } 38 | -------------------------------------------------------------------------------- /external/tonc/code/basic/m3_demo/m3_demo.c: -------------------------------------------------------------------------------- 1 | // 2 | // m3_demo.c 3 | // Basic mode 3 drawing routines 4 | // 5 | // (20060104 - 20060104, cearn) 6 | 7 | #include "toolbox.h" 8 | 9 | int main() 10 | { 11 | int ii, jj; 12 | 13 | REG_DISPCNT= DCNT_MODE3 | DCNT_BG2; 14 | 15 | // Fill screen with gray color 16 | m3_fill(RGB15(12, 12, 14)); 17 | 18 | // Rectangles: 19 | m3_rect( 12, 8, 108, 72, CLR_RED); 20 | m3_rect(108, 72, 132, 88, CLR_LIME); 21 | m3_rect(132, 88, 228, 152, CLR_BLUE); 22 | 23 | // Rectangle frames 24 | m3_frame(132, 8, 228, 72, CLR_CYAN); 25 | m3_frame(109, 73, 131, 87, CLR_BLACK); 26 | m3_frame( 12, 88, 108, 152, CLR_YELLOW); 27 | 28 | // Lines in top right frame 29 | for(ii=0; ii<=8; ii++) 30 | { 31 | jj= 3*ii+7; 32 | m3_line(132+11*ii, 9, 226, 12+7*ii, RGB15(jj, 0, jj)); 33 | m3_line(226-11*ii,70, 133, 69-7*ii, RGB15(jj, 0, jj)); 34 | } 35 | 36 | // Lines in bottom left frame 37 | for(ii=0; ii<=8; ii++) 38 | { 39 | jj= 3*ii+7; 40 | m3_line(15+11*ii, 88, 104-11*ii, 150, RGB15(0, jj, jj)); 41 | } 42 | 43 | while(1); 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /debugger/src/dbg/tracked_value.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default, Copy, Clone)] 2 | pub struct TrackedValue { 3 | value: T, 4 | changed: bool, 5 | } 6 | 7 | impl std::fmt::Display for TrackedValue 8 | where 9 | T: std::fmt::Display, 10 | { 11 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 12 | write!(f, "{}", self.value) 13 | } 14 | } 15 | 16 | impl std::fmt::Debug for TrackedValue 17 | where 18 | T: std::fmt::Debug, 19 | { 20 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 21 | write!(f, "{:?}", self.value) 22 | } 23 | } 24 | 25 | impl TrackedValue 26 | where 27 | T: Copy + PartialEq, 28 | { 29 | pub fn set(&mut self, value: T) { 30 | if value != self.value { 31 | self.value = value; 32 | self.changed = true; 33 | } else { 34 | self.changed = false; 35 | } 36 | } 37 | 38 | pub fn get(&self) -> T { 39 | self.value 40 | } 41 | 42 | pub fn has_changed(&self) -> bool { 43 | self.changed 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /external/tonc/code/basic/pageflip/pageflip.c: -------------------------------------------------------------------------------- 1 | // 2 | // pageflip.c 3 | // Shows mode4 page flipping 4 | // 5 | // (20031003 - 20060922, Cearn) 6 | 7 | #include 8 | 9 | #include "toolbox.h" 10 | #include "page_pic.h" 11 | 12 | void load_gfx() 13 | { 14 | int ii; 15 | for(ii=0; ii<16; ii++) 16 | { 17 | memcpy(&vid_mem_front[ii*120], &frontBitmap[ii*144/4], 144); 18 | memcpy(&vid_mem_back[ii*120], &backBitmap[ii*144/4], 144); 19 | } 20 | 21 | // You don't have to do everything with memcpy. 22 | // In fact, for small blocks it might be better if you didn't. 23 | // Just mind your types, though. No sense in copying from a 32bit 24 | // array to a 16bit one. 25 | u32 *dst= (u32*)pal_bg_mem; 26 | for(ii=0; ii<8; ii++) 27 | dst[ii]= frontPal[ii]; 28 | } 29 | 30 | int main() 31 | { 32 | load_gfx(); 33 | REG_DISPCNT= DCNT_MODE4 | DCNT_BG2; 34 | 35 | int ii=0; 36 | 37 | while(1) 38 | { 39 | while(KEY_DOWN_NOW(KEY_START)) ; // pause with start 40 | 41 | vid_vsync(); 42 | if(++ii == 60) 43 | { 44 | ii=0; 45 | vid_flip(); 46 | } 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /gba-core/src/input/registers.rs: -------------------------------------------------------------------------------- 1 | use bitflags::bitflags; 2 | 3 | bitflags! { 4 | #[derive(Debug)] 5 | pub struct KeyInput: u16 { 6 | const A = 1 << 0; 7 | const B = 1 << 1; 8 | const SELECT = 1 << 2; 9 | const START = 1 << 3; 10 | const RIGHT = 1 << 4; 11 | const LEFT = 1 << 5; 12 | const UP = 1 << 6; 13 | const DOWN = 1 << 7; 14 | const R = 1 << 8; 15 | const L = 1 << 9; 16 | } 17 | } 18 | 19 | bitflags! { 20 | pub struct KeyControl: u16 { 21 | const A = 1 << 0; 22 | const B = 1 << 1; 23 | const SELECT = 1 << 2; 24 | const START = 1 << 3; 25 | const RIGHT = 1 << 4; 26 | const LEFT = 1 << 5; 27 | const UP = 1 << 6; 28 | const DOWN = 1 << 7; 29 | const R = 1 << 8; 30 | const L = 1 << 9; 31 | const IRQ_ENABLE = 1 << 14; 32 | const IRQ_CONDITION = 1 << 15; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /external/tonc/code/vc6/tonc.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "tonc"=.\tonc.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "tonclib"=..\tonclib\tonclib.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "vault"=.\vault.dsp - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Global: 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<3> 49 | {{{ 50 | }}} 51 | 52 | ############################################################################### 53 | 54 | -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_demo/m7_demo.pnproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/tonc/code/basic/key_demo/key_demo.c: -------------------------------------------------------------------------------- 1 | // 2 | // key_demo.c 3 | // 4 | // demonstating key states (and minor palette animation) 5 | // 6 | // (20030927 - 20060922, cearn) 7 | 8 | #include 9 | 10 | #include "toolbox.h" 11 | #include "input.h" 12 | 13 | #include "gba_pic.h" 14 | 15 | #define BTN_PAL 5 16 | #define CLR_UP RGB15(27,27,29) 17 | 18 | 19 | int main() 20 | { 21 | int ii; 22 | u32 btn; 23 | COLOR clr; 24 | int frame=0; 25 | 26 | memcpy(vid_mem, gba_picBitmap, gba_picBitmapLen); 27 | memcpy(pal_bg_mem, gba_picPal, gba_picPalLen); 28 | 29 | REG_DISPCNT= DCNT_MODE4 | DCNT_BG2; 30 | 31 | while(1) 32 | { 33 | vid_vsync(); 34 | // slowing down polling to make the changes visible 35 | if((frame & 7) == 0) 36 | key_poll(); 37 | // check state of each button 38 | for(ii=0; ii -------------------------------------------------------------------------------- /external/tonc/code/ext/swi_vsync/swi_vsync.c: -------------------------------------------------------------------------------- 1 | // 2 | // swi_vsync.c 3 | // Vsyncing with BIOS call 5 4 | // 5 | // (Created: 20040602 - 20060928, Cearn) 6 | 7 | #include 8 | #include "metr.h" 9 | 10 | void init_main() 11 | { 12 | // The obvious initialisations 13 | REG_DISPCNT= DCNT_OBJ | DCNT_OBJ_1D; 14 | oam_init(oam_mem, 128); 15 | 16 | // Get the tiles & palette 17 | memcpy32(&tile_mem[4][0], metr_boxTiles, metr_boxTilesLen/4); 18 | memcpy32(pal_obj_mem, metrPal, metrPalLen/4); 19 | 20 | // Initialize the metroid sprite 21 | OBJ_ATTR *metr= &oam_mem[0]; 22 | obj_set_attr(metr, ATTR0_SQUARE | ATTR0_AFF_DBL, 23 | ATTR1_SIZE_64 | ATTR1_AFF_ID(0), 0); 24 | obj_set_pos(metr, 120-64, 80-64); 25 | } 26 | 27 | int main() 28 | { 29 | AFF_SRC as= { 0x0100, 0x0100, 0 }; 30 | OBJ_AFFINE oaff; 31 | 32 | init_main(); 33 | 34 | // Init interrupts, and enable VBlank irq 35 | irq_init(NULL); 36 | irq_add(II_VBLANK, NULL); 37 | 38 | while(1) 39 | { 40 | VBlankIntrWait(); 41 | 42 | // Full circle = 10000h 43 | // 10000h/4/60= 111h -> 1/4 rev/s = 1 passing corner/s 44 | as.alpha += 0x0111; 45 | ObjAffineSet(&as, &oaff.pa, 1, OBJ_AFF_OFS); 46 | 47 | obj_aff_copy(obj_aff_mem, &oaff, 1); 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /external/tonc/code/basic/cbb_demo/cbb_ids.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // ids8, 72x8@8, 4 | // + 9 tiles not compressed 5 | // Total size: 576 = 576 6 | // 7 | // Time-stamp: 2005-12-24, 18:28:50 8 | // Exported by Cearn's Usenti v1.7.1 9 | // (comments, kudos, flames to "daytshen@hotmail.com") 10 | // 11 | //====================================================================== 12 | 13 | #ifndef __IDS8__ 14 | #define __IDS8__ 15 | 16 | #define ids8TilesLen 576 17 | extern const unsigned int ids8Tiles[144]; 18 | 19 | #endif // __IDS8__ 20 | 21 | //====================================================================== 22 | // 23 | // ids4, 40x8@4, 24 | // + palette 16 entries, not compressed 25 | // + 5 tiles not compressed 26 | // Total size: 32 + 160 = 192 27 | // 28 | // Time-stamp: 2005-12-24, 18:29:29 29 | // Exported by Cearn's Usenti v1.7.1 30 | // (comments, kudos, flames to "daytshen@hotmail.com") 31 | // 32 | //====================================================================== 33 | 34 | #ifndef __IDS4__ 35 | #define __IDS4__ 36 | 37 | #define ids4PalLen 32 38 | extern const unsigned int ids4Pal[8]; 39 | 40 | #define ids4TilesLen 160 41 | extern const unsigned int ids4Tiles[40]; 42 | 43 | #endif // __IDS4__ 44 | 45 | -------------------------------------------------------------------------------- /external/tonc/code/basic/pageflip/page_pic.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // front, 144x16@8, 4 | // + palette 16 entries, not compressed 5 | // + bitmap not compressed 6 | // Total size: 32 + 2304 = 2336 7 | // 8 | // Time-stamp: 2005-12-24, 15:30:24 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __FRONT__ 15 | #define __FRONT__ 16 | 17 | #define frontPalLen 32 18 | extern const unsigned int frontPal[8]; 19 | 20 | #define frontBitmapLen 2304 21 | extern const unsigned int frontBitmap[576]; 22 | 23 | #endif // __FRONT__ 24 | 25 | //====================================================================== 26 | // 27 | // back, 144x16@8, 28 | // + bitmap not compressed 29 | // Total size: 2304 = 2304 30 | // 31 | // Time-stamp: 2005-12-24, 15:30:41 32 | // Exported by Cearn's Usenti v1.7.1 33 | // (comments, kudos, flames to "daytshen@hotmail.com") 34 | // 35 | //====================================================================== 36 | 37 | #ifndef __BACK__ 38 | #define __BACK__ 39 | 40 | #define backBitmapLen 2304 41 | extern const unsigned int backBitmap[576]; 42 | 43 | #endif // __BACK__ 44 | 45 | -------------------------------------------------------------------------------- /external/tonc/code/basic/obj_demo/metr.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // metr, 64x64@4, 4 | // + palette 32 entries, not compressed 5 | // + 64 tiles not compressed 6 | // Total size: 64 + 2048 = 2112 7 | // 8 | // Time-stamp: 2005-12-24, 17:36:57 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __METR__ 15 | #define __METR__ 16 | 17 | #define metrPalLen 64 18 | extern const unsigned int metrPal[16]; 19 | 20 | #define metrTilesLen 2048 21 | extern const unsigned int metrTiles[512]; 22 | 23 | #endif // __METR__ 24 | 25 | //====================================================================== 26 | // 27 | // metr_box, 64x64@4, 28 | // + 64 tiles not compressed 29 | // Total size: 2048 = 2048 30 | // 31 | // Time-stamp: 2005-12-24, 17:37:08 32 | // Exported by Cearn's Usenti v1.7.1 33 | // (comments, kudos, flames to "daytshen@hotmail.com") 34 | // 35 | //====================================================================== 36 | 37 | #ifndef __METR_BOX__ 38 | #define __METR_BOX__ 39 | 40 | #define metr_boxTilesLen 2048 41 | extern const unsigned int metr_boxTiles[512]; 42 | 43 | #endif // __METR_BOX__ 44 | 45 | -------------------------------------------------------------------------------- /external/tonc/code/ext/bld_demo/metr.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // metr, 64x64@4, 4 | // + palette 32 entries, not compressed 5 | // + 64 tiles not compressed 6 | // Total size: 64 + 2048 = 2112 7 | // 8 | // Time-stamp: 2005-12-24, 17:36:57 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __METR__ 15 | #define __METR__ 16 | 17 | #define metrPalLen 64 18 | extern const unsigned int metrPal[16]; 19 | 20 | #define metrTilesLen 2048 21 | extern const unsigned int metrTiles[512]; 22 | 23 | #endif // __METR__ 24 | 25 | //====================================================================== 26 | // 27 | // metr_box, 64x64@4, 28 | // + 64 tiles not compressed 29 | // Total size: 2048 = 2048 30 | // 31 | // Time-stamp: 2005-12-24, 17:37:08 32 | // Exported by Cearn's Usenti v1.7.1 33 | // (comments, kudos, flames to "daytshen@hotmail.com") 34 | // 35 | //====================================================================== 36 | 37 | #ifndef __METR_BOX__ 38 | #define __METR_BOX__ 39 | 40 | #define metr_boxTilesLen 2048 41 | extern const unsigned int metr_boxTiles[512]; 42 | 43 | #endif // __METR_BOX__ 44 | 45 | -------------------------------------------------------------------------------- /external/tonc/code/ext/mos_demo/metr.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // metr, 64x64@4, 4 | // + palette 32 entries, not compressed 5 | // + 64 tiles not compressed 6 | // Total size: 64 + 2048 = 2112 7 | // 8 | // Time-stamp: 2005-12-24, 17:36:57 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __METR__ 15 | #define __METR__ 16 | 17 | #define metrPalLen 64 18 | extern const unsigned int metrPal[16]; 19 | 20 | #define metrTilesLen 2048 21 | extern const unsigned int metrTiles[512]; 22 | 23 | #endif // __METR__ 24 | 25 | //====================================================================== 26 | // 27 | // metr_box, 64x64@4, 28 | // + 64 tiles not compressed 29 | // Total size: 2048 = 2048 30 | // 31 | // Time-stamp: 2005-12-24, 17:37:08 32 | // Exported by Cearn's Usenti v1.7.1 33 | // (comments, kudos, flames to "daytshen@hotmail.com") 34 | // 35 | //====================================================================== 36 | 37 | #ifndef __METR_BOX__ 38 | #define __METR_BOX__ 39 | 40 | #define metr_boxTilesLen 2048 41 | extern const unsigned int metr_boxTiles[512]; 42 | 43 | #endif // __METR_BOX__ 44 | 45 | -------------------------------------------------------------------------------- /external/tonc/code/ext/obj_aff/metr.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // metr, 64x64@4, 4 | // + palette 32 entries, not compressed 5 | // + 64 tiles not compressed 6 | // Total size: 64 + 2048 = 2112 7 | // 8 | // Time-stamp: 2005-12-24, 17:36:57 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __METR__ 15 | #define __METR__ 16 | 17 | #define metrPalLen 64 18 | extern const unsigned int metrPal[16]; 19 | 20 | #define metrTilesLen 2048 21 | extern const unsigned int metrTiles[512]; 22 | 23 | #endif // __METR__ 24 | 25 | //====================================================================== 26 | // 27 | // metr_box, 64x64@4, 28 | // + 64 tiles not compressed 29 | // Total size: 2048 = 2048 30 | // 31 | // Time-stamp: 2005-12-24, 17:37:08 32 | // Exported by Cearn's Usenti v1.7.1 33 | // (comments, kudos, flames to "daytshen@hotmail.com") 34 | // 35 | //====================================================================== 36 | 37 | #ifndef __METR_BOX__ 38 | #define __METR_BOX__ 39 | 40 | #define metr_boxTilesLen 2048 41 | extern const unsigned int metr_boxTiles[512]; 42 | 43 | #endif // __METR_BOX__ 44 | 45 | -------------------------------------------------------------------------------- /external/tonc/code/ext/swi_vsync/metr.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // metr, 64x64@4, 4 | // + palette 32 entries, not compressed 5 | // + 64 tiles not compressed 6 | // Total size: 64 + 2048 = 2112 7 | // 8 | // Time-stamp: 2005-12-24, 17:36:57 9 | // Exported by Cearn's Usenti v1.7.1 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | #ifndef __METR__ 15 | #define __METR__ 16 | 17 | #define metrPalLen 64 18 | extern const unsigned int metrPal[16]; 19 | 20 | #define metrTilesLen 2048 21 | extern const unsigned int metrTiles[512]; 22 | 23 | #endif // __METR__ 24 | 25 | //====================================================================== 26 | // 27 | // metr_box, 64x64@4, 28 | // + 64 tiles not compressed 29 | // Total size: 2048 = 2048 30 | // 31 | // Time-stamp: 2005-12-24, 17:37:08 32 | // Exported by Cearn's Usenti v1.7.1 33 | // (comments, kudos, flames to "daytshen@hotmail.com") 34 | // 35 | //====================================================================== 36 | 37 | #ifndef __METR_BOX__ 38 | #define __METR_BOX__ 39 | 40 | #define metr_boxTilesLen 2048 41 | extern const unsigned int metr_boxTiles[512]; 42 | 43 | #endif // __METR_BOX__ 44 | 45 | -------------------------------------------------------------------------------- /external/tonc/code/lab/bigmap/link.h: -------------------------------------------------------------------------------- 1 | // 2 | // Sprite Link movement 3 | // 4 | //! \file link.h 5 | //! \author J Vijn 6 | //! \date 20070216 - 20070216 7 | // 8 | // === NOTES === 9 | 10 | 11 | #ifndef __LINK__ 12 | #define __LINK__ 13 | 14 | 15 | // === CONSTANTS ====================================================== 16 | 17 | enum ELookDir 18 | { 19 | LOOK_RIGHT= 0, LOOK_DOWN, LOOK_LEFT, LOOK_UP, 20 | }; 21 | 22 | #define SPR_STATE_STAND 0x0100 23 | #define SPR_STATE_WALK 0x0200 24 | 25 | // === CLASSES ======================================================== 26 | 27 | typedef struct TSprite 28 | { 29 | FIXED x, y; //!< Position 30 | FIXED vx, vy; //!< Velocity 31 | u16 state; //!< Sprite state 32 | u8 dir; //!< Look direction 33 | u8 objId; //!< Object index 34 | FIXED aniFrame; //!< Animation frame counter 35 | } TSprite; 36 | 37 | #endif // __LINK__ 38 | 39 | 40 | // -------------------------------------------------------------------- 41 | // PROTOTYPES 42 | // -------------------------------------------------------------------- 43 | 44 | void link_init(TSprite *link, int x, int y, int obj_id); 45 | void link_set_state(TSprite *link, u32 state); 46 | void link_input(TSprite *link); 47 | 48 | void link_move(TSprite *link); 49 | void link_animate(TSprite *link); 50 | 51 | 52 | 53 | // EOF 54 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/base.h: -------------------------------------------------------------------------------- 1 | // 2 | // [[ ]] 3 | // 4 | //! \file [[ ]] 5 | //! \author J Vijn 6 | //! \date 20060508 - 20060508 7 | // 8 | /* === NOTES === 9 | */ 10 | 11 | #ifndef TONC_XXX 12 | #define TONC_XXX 13 | 14 | #include "tonc_memmap.h" 15 | 16 | // -------------------------------------------------------------------- 17 | // CONSTANTS 18 | // -------------------------------------------------------------------- 19 | // -------------------------------------------------------------------- 20 | // MACROS 21 | // -------------------------------------------------------------------- 22 | 23 | // -------------------------------------------------------------------- 24 | // CLASSES 25 | // -------------------------------------------------------------------- 26 | 27 | 28 | // -------------------------------------------------------------------- 29 | // GLOBALS 30 | // -------------------------------------------------------------------- 31 | 32 | 33 | // -------------------------------------------------------------------- 34 | // PROTOTYPES 35 | // -------------------------------------------------------------------- 36 | 37 | 38 | 39 | // -------------------------------------------------------------------- 40 | // INLINES 41 | // -------------------------------------------------------------------- 42 | 43 | 44 | #endif // TONC_XXX 45 | 46 | // EOF 47 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/base.c: -------------------------------------------------------------------------------- 1 | // 2 | // [[ ]] 3 | // 4 | //! \file [[ ]] 5 | //! \author J Vijn 6 | //! \date 20079021 - 20079021 7 | // 8 | /* === NOTES === 9 | */ 10 | 11 | #include "tonc_memmap.h" 12 | 13 | // -------------------------------------------------------------------- 14 | // CONSTANTS 15 | // -------------------------------------------------------------------- 16 | 17 | // -------------------------------------------------------------------- 18 | // CLASSES 19 | // -------------------------------------------------------------------- 20 | 21 | 22 | // -------------------------------------------------------------------- 23 | // GLOBALS 24 | // -------------------------------------------------------------------- 25 | 26 | 27 | 28 | // -------------------------------------------------------------------- 29 | // PROTOTYPES 30 | // -------------------------------------------------------------------- 31 | 32 | 33 | // -------------------------------------------------------------------- 34 | // MACROS 35 | // -------------------------------------------------------------------- 36 | // === INLINES========================================================= 37 | 38 | // -------------------------------------------------------------------- 39 | // FUNCTIONS 40 | // -------------------------------------------------------------------- 41 | 42 | 43 | // EOF 44 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/include/tonc_nocash.h: -------------------------------------------------------------------------------- 1 | // 2 | // no$gba messaging functionality 3 | // 4 | //! \file tonc_nocash.h 5 | //! \author J Vijn 6 | //! \date 20080422 - 20080422 7 | // 8 | /* === NOTES === 9 | */ 10 | 11 | #ifndef TONC_NOCASH 12 | #define TONC_NOCASH 13 | 14 | #include "tonc_types.h" 15 | 16 | /*! \defgroup grpNocash no$gba debugging 17 | \ingroup grpCore 18 | The non-freeware versions of no$gba have window to which you 19 | can output messages for debugging purposes. These functions allow 20 | you to work with that. 21 | */ 22 | 23 | 24 | /*! \addtogroup grpNocash */ 25 | /*! \{ */ 26 | 27 | // -------------------------------------------------------------------- 28 | // GLOBALS 29 | // -------------------------------------------------------------------- 30 | 31 | extern EWRAM_DATA char nocash_buffer[80]; 32 | 33 | // -------------------------------------------------------------------- 34 | // PROTOTYPES 35 | // -------------------------------------------------------------------- 36 | 37 | //! Output a string to no$gba debugger. 38 | /*! 39 | \param str Text to print. 40 | \return Number of characters printed. 41 | */ 42 | int nocash_puts(const char *str); 43 | 44 | //! Print the current \a nocash_buffer to the no$gba debugger. 45 | EWRAM_CODE void nocash_message(void); 46 | 47 | /*! \} */ 48 | 49 | #endif // TONC_NOCASH 50 | 51 | // EOF 52 | -------------------------------------------------------------------------------- /gba-core/src/arm7tdmi/symbolizer.rs: -------------------------------------------------------------------------------- 1 | use goblin::Object; 2 | use std::collections::HashMap; 3 | use tracing::info; 4 | 5 | pub struct Symbolizer { 6 | symbols: HashMap>, 7 | } 8 | 9 | impl Symbolizer { 10 | pub fn new(buffer: &[u8]) -> Symbolizer { 11 | let elf = match Object::parse(&buffer) { 12 | Ok(Object::Elf(elf)) => elf, 13 | _ => { 14 | // If the buffer is empty, we'll assume no ELF was found 15 | return Symbolizer { 16 | symbols: HashMap::new(), 17 | }; 18 | } 19 | }; 20 | 21 | let symbols: HashMap> = elf 22 | .syms 23 | .iter() 24 | .filter_map(|sym| { 25 | elf.strtab 26 | .get_at(sym.st_name) 27 | .and_then(|name| (!name.is_empty()).then(|| (sym.st_value as u32, name.to_string()))) 28 | }) 29 | .fold(HashMap::new(), |mut map, (addr, name)| { 30 | map.entry(addr).or_default().push(name); 31 | map 32 | }); 33 | 34 | info!(target: "symbols", "Loaded {} symbols", symbols.len()); 35 | 36 | Symbolizer { symbols } 37 | } 38 | 39 | pub fn find(&self, addr: u32) -> Option<&Vec> { 40 | self.symbols.get(&addr) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /external/tonc/code/ext/tmr_demo/tmr_demo.c: -------------------------------------------------------------------------------- 1 | // 2 | // tmr_demo.c 3 | // Demonstrating a cascade timer 4 | // Using a slightly modified version of berk.gif from Headspin's fonts. 5 | // Press start to start timer. 6 | // 7 | // (20031220 -20070809, Cearn) 8 | 9 | #include 10 | #include 11 | 12 | #include "berk.h" 13 | 14 | 15 | void tmr_test() 16 | { 17 | // Overflow every ~1 second: 18 | // 0x4000 ticks @ FREQ_1024 19 | 20 | REG_TM2D= -0x4000; // 0x4000 ticks till overflow 21 | REG_TM2CNT= TM_FREQ_1024; // we're using the 1024 cycle timer 22 | 23 | // cascade into tm3 24 | REG_TM3CNT= TM_ENABLE | TM_CASCADE; 25 | 26 | u32 sec= -1; 27 | 28 | while(1) 29 | { 30 | vid_vsync(); 31 | key_poll(); 32 | 33 | if(REG_TM3D != sec) 34 | { 35 | sec= REG_TM3D; 36 | tte_printf("#{es;P:24,60}%02d:%02d:%02d", 37 | sec/3600, (sec%3600)/60, sec%60); 38 | } 39 | 40 | if(key_hit(KEY_START)) // pause by disabling timer 41 | REG_TM2CNT ^= TM_ENABLE; 42 | 43 | if(key_hit(KEY_SELECT)) // pause by enabling cascade 44 | REG_TM2CNT ^= TM_CASCADE; 45 | } 46 | } 47 | 48 | int main() 49 | { 50 | // set-up berk font 51 | tte_init_se(0, BG_CBB(0)|BG_SBB(31), 1, 0, 0, &berkFont, se_drawg); 52 | tte_init_con(); 53 | memcpy16(pal_bg_mem, berkPal, berkPalLen/4); 54 | 55 | REG_DISPCNT= DCNT_MODE0 | DCNT_BG0; 56 | 57 | tmr_test(); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tonc_math.c: -------------------------------------------------------------------------------- 1 | // 2 | // Basic math functions 3 | // 4 | //! \file tonc_math.c 5 | //! \author J Vijn 6 | //! \date 20060508 - 20060508 7 | // 8 | // === NOTES === 9 | 10 | #include "tonc_memmap.h" 11 | #include "tonc_core.h" 12 | #include "tonc_math.h" 13 | 14 | 15 | // -------------------------------------------------------------------- 16 | // FUNCTIONS 17 | // -------------------------------------------------------------------- 18 | 19 | 20 | // --- Geometry ------------------------------------------------------- 21 | 22 | // --- Point functions --- 23 | 24 | //! Is a point inside a rectangle 25 | int pt_in_rect(const POINT *pt, const RECT *rc) 26 | { 27 | if(pt->x < rc->left || pt->x >= rc->right) 28 | return 0; 29 | if(pt->y < rc->top || pt->y >= rc->bottom) 30 | return 0; 31 | return 1; 32 | } 33 | 34 | // --- Vector functions --- 35 | 36 | VECTOR *vec_cross(VECTOR *vd, const VECTOR *va, const VECTOR *vb) 37 | { 38 | vd->x= fxmul(va->y, vb->z) - fxmul(va->z,vb->y); 39 | vd->y= fxmul(va->y, vb->z) - fxmul(va->z,vb->y); 40 | vd->z= fxmul(va->y, vb->z) - fxmul(va->z,vb->y); 41 | return vd; 42 | } 43 | 44 | // --- Rect functions --- 45 | 46 | RECT *rc_normalize(RECT *rc) 47 | { 48 | int tmp; 49 | if(rc->left > rc->right) 50 | SWAP3(rc->left, rc->right, tmp); 51 | if(rc->top > rc->bottom) 52 | SWAP3(rc->top, rc->bottom, tmp); 53 | return rc; 54 | } 55 | -------------------------------------------------------------------------------- /scripts/example.rhai: -------------------------------------------------------------------------------- 1 | /* 2 | fn dump_stack() { 3 | let sp = cpu.read_register("sp"); 4 | println(`Stack @ ${hex32(sp)}:`); 5 | 6 | for i in -16..=16 { 7 | let addr = sp + (i * 4); 8 | let value = mmio.read_u32(addr); 9 | let offset = if i < 0 { 10 | "-" + padleft(`${-1 * i}`, "0", 2) 11 | } else { 12 | "+" + padleft(`${i}`, "0", 2) 13 | }; 14 | println(`${hex32(addr)} [${offset}]: ${hex32(value)}`); 15 | } 16 | } 17 | 18 | fn print_opcode() { 19 | let dump = ""; 20 | 21 | for i in 0..4 { 22 | let pc = 0x0801ad2a + i; 23 | let value = mmio.read_u8(pc); 24 | dump += `${hex8(value)}`; 25 | } 26 | 27 | println(`${dump}`); 28 | } 29 | */ 30 | 31 | fn dump_attr2() { 32 | let attr2 = emu.read_u16(0x07000004); 33 | let name = (attr2 & 0b0000_0011_1111_1111); 34 | let prio = (attr2 & 0b0000_1100_0000_0000) >> 10; 35 | let plnr = (attr2 & 0b1111_0000_0000_0000) >> 12; 36 | println(`ATTR2: ${bin16(attr2)} -> Name: ${name}, Prio: ${prio}, Palette: ${plnr}`); 37 | } 38 | 39 | fn setup() { 40 | let breakpoints = #{ 41 | // "0x08008644": "dump_stack", 42 | // "0x0800865c": "dump_stack", 43 | // "0x08008588": "dump_stack", 44 | // "0x0801ad2a": "print_opcode", 45 | "0x00000C20": "dump_attr2" 46 | }; 47 | breakpoints 48 | } 49 | -------------------------------------------------------------------------------- /external/tonc/code/basic/second/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the second first demo 3 | # 4 | # NOTE: for educational purposes only. For real work, use 5 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 6 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 7 | 8 | PATH := $(DEVKITARM)/bin:$(PATH) 9 | 10 | # --- Project details ------------------------------------------------- 11 | 12 | PROJ := second 13 | TITLE := $(PROJ) 14 | TARGET := $(PROJ) 15 | 16 | OBJS := $(PROJ).o 17 | 18 | # --- Build defines --------------------------------------------------- 19 | 20 | CROSS := arm-none-eabi- 21 | CC := $(CROSS)gcc 22 | LD := $(CROSS)gcc 23 | OBJCOPY := $(CROSS)objcopy 24 | 25 | ARCH := -mthumb-interwork -mthumb 26 | SPECS := -specs=gba.specs 27 | 28 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 29 | LDFLAGS := $(ARCH) $(SPECS) 30 | 31 | 32 | .PHONY : build clean 33 | 34 | # --- Build ----------------------------------------------------------- 35 | 36 | build: $(TARGET).gba 37 | 38 | $(TARGET).gba : $(TARGET).elf 39 | $(OBJCOPY) -v -O binary $< $@ 40 | -@gbafix $@ -t$(TITLE) 41 | 42 | $(TARGET).elf : $(OBJS) 43 | $(LD) $^ $(LDFLAGS) -o $@ 44 | 45 | $(OBJS) : %.o : %.c 46 | $(CC) -c $< $(CFLAGS) -o $@ 47 | 48 | # --- Clean ----------------------------------------------------------- 49 | 50 | clean : 51 | @rm -fv *.gba 52 | @rm -fv *.elf 53 | @rm -fv *.o 54 | 55 | #EOF 56 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tonc_bg.c: -------------------------------------------------------------------------------- 1 | // 2 | // Tiled background stuff 3 | // 4 | //! \file tonc_bg.c 5 | //! \author J Vijn 6 | //! \date 20061112 - 20061117 7 | // 8 | // === NOTES === 9 | // * Empty, isn't it :P 10 | 11 | 12 | #include "tonc_memmap.h" 13 | #include "tonc_video.h" 14 | 15 | 16 | // -------------------------------------------------------------------- 17 | // FUNCTIONS 18 | // -------------------------------------------------------------------- 19 | 20 | 21 | //! Create a framed rectangle. 22 | /*! In contrast to se_frame(), se_frame_ex() uses nine tiles starting at 23 | \a se0 for the frame, which indicate the borders and center for the 24 | window. 25 | \note Rectangle is nor normalized. 26 | */ 27 | void se_window(SCR_ENTRY *sbb, int left, int top, int right, int bottom, 28 | SCR_ENTRY se0) 29 | { 30 | int ix, iy; 31 | right -= (left+1); 32 | bottom -= (top+1); 33 | 34 | sbb += top*32+left; 35 | 36 | sbb[ 0]= se0; 37 | sbb[ right]= se0+2; 38 | sbb[bottom*32 ]= se0+6; 39 | sbb[bottom*32+right]= se0+8; 40 | 41 | // horizontal 42 | for(ix=1; ix>2; 27 | u32 *dst= (u32*)obj; 28 | 29 | // Hide all and set OBJ_AFFINEs to I 30 | while(nn--) 31 | { 32 | *dst++= ATTR0_HIDE; 33 | *dst++= 0x0100<<16; 34 | *dst++= ATTR0_HIDE; 35 | *dst++= 0; 36 | *dst++= ATTR0_HIDE; 37 | *dst++= 0; 38 | *dst++= ATTR0_HIDE; 39 | *dst++= 0x0100<<16; 40 | } 41 | // init oam 42 | oam_copy(oam_mem, obj, count); 43 | } 44 | 45 | //! Copy attributes 0-2 in \a count OBJ_ATTRs. 46 | void obj_copy(OBJ_ATTR *dst, const OBJ_ATTR *src, u32 count) 47 | { 48 | int ii; 49 | for(ii=0; ii ProcessorMode { 18 | match value { 19 | 0b10000 => ProcessorMode::User, 20 | 0b10001 => ProcessorMode::Fiq, 21 | 0b10010 => ProcessorMode::Irq, 22 | 0b10011 => ProcessorMode::Supervisor, 23 | 0b10111 => ProcessorMode::Abort, 24 | 0b11011 => ProcessorMode::Undefined, 25 | 0b11111 => ProcessorMode::System, 26 | _ => { 27 | error!(target: "cpu", "Invalid processor mode: {:08b}", value); 28 | ProcessorMode::Invalid 29 | } 30 | } 31 | } 32 | } 33 | 34 | impl Display for ProcessorMode { 35 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 36 | match self { 37 | ProcessorMode::User => write!(f, "User"), 38 | ProcessorMode::Fiq => write!(f, "Fiq"), 39 | ProcessorMode::Irq => write!(f, "Irq"), 40 | ProcessorMode::Supervisor => write!(f, "Supervisor"), 41 | ProcessorMode::Abort => write!(f, "Abort"), 42 | ProcessorMode::System => write!(f, "System"), 43 | ProcessorMode::Undefined => write!(f, "Undefined"), 44 | ProcessorMode::Invalid => write!(f, "Invalid"), 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /external/tonc/code/basic/m3_demo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for mde 3 drawing demo 3 | # 4 | # NOTE: for educational purposes only. For real work, use 5 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 6 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 7 | 8 | PATH := $(DEVKITARM)/bin:$(PATH) 9 | 10 | # --- Project details ------------------------------------------------- 11 | 12 | PROJ := m3_demo 13 | TITLE := $(PROJ) 14 | 15 | COBJS := m3_demo.o toolbox.o 16 | 17 | OBJS := $(COBJS) 18 | 19 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 20 | 21 | MB = 0 22 | 23 | ifeq ($(MB),1) 24 | 25 | TARGET := $(PROJ).mb 26 | SPECS := -specs=gba_mb.specs 27 | 28 | else 29 | 30 | TARGET := $(PROJ) 31 | SPECS := -specs=gba.specs 32 | 33 | endif 34 | 35 | # --- Compiling ------------------------------------------------------- 36 | 37 | CROSS ?= arm-none-eabi- 38 | AS := $(CROSS)as 39 | CC := $(CROSS)gcc 40 | LD := $(CROSS)gcc 41 | OBJCOPY := $(CROSS)objcopy 42 | 43 | 44 | ARCH := -mthumb-interwork -mthumb 45 | 46 | ASFLAGS := -mthumb-interwork 47 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 48 | LDFLAGS := $(ARCH) $(SPECS) 49 | 50 | .PHONY : build clean 51 | 52 | # --- Build ----------------------------------------------------------- 53 | 54 | build : $(TARGET).gba 55 | 56 | 57 | $(TARGET).gba : $(TARGET).elf 58 | $(OBJCOPY) -v -O binary $< $@ 59 | -@gbafix $@ -t$(TITLE) 60 | 61 | $(TARGET).elf : $(OBJS) 62 | $(LD) $^ $(LDFLAGS) -o $@ 63 | 64 | $(COBJS) : %.o : %.c 65 | $(CC) $(CFLAGS) -c $< -o $@ 66 | 67 | # --- Clean ----------------------------------------------------------- 68 | 69 | clean : 70 | @rm -fv *.gba 71 | @rm -fv *.elf 72 | @rm -fv *.o 73 | 74 | #EOF 75 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tte/obj_drawg.c: -------------------------------------------------------------------------------- 1 | // 2 | // Object plotter 3 | // 4 | //! \file obj_drawg.c 5 | //! \author J Vijn 6 | //! \date 20070715 - 20070822 7 | // 8 | /* === NOTES === 9 | * 20070715: The object system works a little differently than the 10 | others. Objects are used as a descending stack with dstPitch as the 11 | backwards obj index. Also, INK, SHADOW and SPECIAL are base 12 | attributes of the objects. obj_erase unwinds the whole obj-stack. 13 | */ 14 | 15 | #include "tonc_types.h" 16 | #include "tonc_memdef.h" 17 | #include "tonc_core.h" 18 | #include "tonc_oam.h" 19 | 20 | #include "tonc_tte.h" 21 | 22 | 23 | //! Unwind the object text-buffer 24 | void obj_erase(int left, int top, int right, int bottom) 25 | { 26 | TTC *tc= tte_get_context(); 27 | int ii=0, nn= tc->dst.pitch; 28 | OBJ_ATTR *obj= (OBJ_ATTR*)tc->dst.data; 29 | 30 | for(ii=0; iidst.pitch= 0; 34 | } 35 | 36 | 37 | // -------------------------------------------------------------------- 38 | // drawg routines 39 | // -------------------------------------------------------------------- 40 | 41 | 42 | //! Character-plot for objects. 43 | void obj_drawg(uint gid) 44 | { 45 | // PONDER: no obj for ' ' ? 46 | 47 | TTC *tc= tte_get_context(); 48 | TFont *font= tc->font; 49 | uint x0= tc->cursorX, y0= tc->cursorY; 50 | 51 | uint id= tc->dst.pitch; 52 | OBJ_ATTR *obj= &((OBJ_ATTR*)tc->dst.data)[-id]; 53 | 54 | tc->dst.pitch= (id+1 < tc->dst.width ? id+1 : 0); 55 | 56 | obj->attr0= tc->cattr[0] | BFN_PREP(y0, ATTR0_Y); 57 | obj->attr1= tc->cattr[1] | BFN_PREP(x0, ATTR1_X); 58 | obj->attr2= tc->cattr[2] + gid*font->cellW*font->cellH/64; 59 | } 60 | 61 | // EOF 62 | -------------------------------------------------------------------------------- /external/tonc/code/lab/prio_demo/prio_gfx.c: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // ball, 16x16@4, 4 | // + palette 128 entries, not compressed 5 | // + 4 tiles not compressed 6 | // Total size: 256 + 128 = 384 7 | // 8 | // Time-stamp: 2006-04-09, 19:33:17 9 | // Exported by Cearn's Usenti v1.7.4 10 | // (comments, kudos, flames to "daytshen@hotmail.com") 11 | // 12 | //====================================================================== 13 | 14 | const unsigned int ballPal[64]= 15 | { 16 | 0x21083DFF,0x39CE2D6B,0x56B54A52,0x739C6318,0x10847FFF,0x03FF03E0,0x42107C00,0x001F7FE0, 17 | 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 18 | 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 19 | 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 20 | 0x00103DFF,0x00140012,0x00180016,0x001C001A,0x0000001F,0x00000000,0x00000000,0x00000000, 21 | 0x00083DFF,0x000C000A,0x0011000E,0x00150013,0x00000018,0x00000000,0x00000000,0x00000000, 22 | 0x42007FEF,0x52804A40,0x63005AC0,0x73806B40,0x00007FE0,0x00000000,0x00000000,0x00000000, 23 | 0x21007FEF,0x31802940,0x462039C0,0x56A04E60,0x00006300,0x00000000,0x00000000,0x00000000, 24 | }; 25 | 26 | const unsigned int ballTiles[32]= 27 | { 28 | 0x99900000,0x55590000,0x66651900,0x77765100,0x78876590,0x78876559,0x77776559,0x77765559, 29 | 0x00000999,0x00009455,0x00914455,0x00144556,0x09345567,0x92345567,0x92345567,0x92345556, 30 | 0x66655559,0x55555549,0x55554449,0x44444490,0x33333100,0x33331900,0x22290000,0x99900000, 31 | 0x91344555,0x91344555,0x91234444,0x09123344,0x00122333,0x00911233,0x00009111,0x00000999, 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /external/tonc/code/basic/bm_modes/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for bitmap modes demonstration 3 | # 4 | # NOTE: for educational purposes only. For real work, use 5 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 6 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 7 | 8 | PATH := $(DEVKITARM)/bin:$(PATH) 9 | 10 | # --- Project details ------------------------------------------------- 11 | 12 | PROJ := bm_modes 13 | TITLE := $(PROJ) 14 | 15 | COBJS := bm_modes.o toolbox.o modes.o 16 | 17 | OBJS := $(COBJS) 18 | 19 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 20 | 21 | MB = 0 22 | 23 | ifeq ($(MB),1) 24 | 25 | TARGET := $(PROJ).mb 26 | SPECS := -specs=gba_mb.specs 27 | 28 | else 29 | 30 | TARGET := $(PROJ) 31 | SPECS := -specs=gba.specs 32 | 33 | endif 34 | 35 | # --- Compiling ------------------------------------------------------- 36 | 37 | CROSS ?= arm-none-eabi- 38 | AS := $(CROSS)as 39 | CC := $(CROSS)gcc 40 | LD := $(CROSS)gcc 41 | OBJCOPY := $(CROSS)objcopy 42 | 43 | 44 | ARCH := -mthumb-interwork -mthumb 45 | 46 | ASFLAGS := -mthumb-interwork 47 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 48 | LDFLAGS := $(ARCH) $(SPECS) 49 | 50 | .PHONY : build clean 51 | 52 | # --- Build ----------------------------------------------------------- 53 | 54 | build : $(TARGET).gba 55 | 56 | 57 | $(TARGET).gba : $(TARGET).elf 58 | $(OBJCOPY) -v -O binary $< $@ 59 | -@gbafix $@ -t$(TITLE) 60 | 61 | $(TARGET).elf : $(OBJS) 62 | $(LD) $^ $(LDFLAGS) -o $@ 63 | 64 | $(COBJS) : %.o : %.c 65 | $(CC) $(CFLAGS) -c $< -o $@ 66 | 67 | # --- Clean ----------------------------------------------------------- 68 | 69 | clean : 70 | @rm -fv *.gba 71 | @rm -fv *.elf 72 | @rm -fv *.o 73 | 74 | #EOF 75 | -------------------------------------------------------------------------------- /external/tonc/code/ext/sbb_aff/nums.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // nums, 64x16@4, 4 | // + palette 32 entries, not compressed 5 | // Total size: 64 = 64 6 | // 7 | // Time-stamp: 2005-12-24, 14:34:51 8 | // Exported by Cearn's Usenti v1.7.1 9 | // (comments, kudos, flames to "daytshen@hotmail.com") 10 | // 11 | //====================================================================== 12 | 13 | #ifndef __NUMS__ 14 | #define __NUMS__ 15 | 16 | #define numsPalLen 64 17 | extern const unsigned int numsPal[16]; 18 | 19 | #endif // __NUMS__ 20 | 21 | //====================================================================== 22 | // 23 | // nums4, 64x16@4, 24 | // + 16 tiles not compressed 25 | // Total size: 512 = 512 26 | // 27 | // Time-stamp: 2005-12-24, 14:35:00 28 | // Exported by Cearn's Usenti v1.7.1 29 | // (comments, kudos, flames to "daytshen@hotmail.com") 30 | // 31 | //====================================================================== 32 | 33 | #ifndef __NUMS4__ 34 | #define __NUMS4__ 35 | 36 | #define nums4TilesLen 512 37 | extern const unsigned int nums4Tiles[128]; 38 | 39 | #endif // __NUMS4__ 40 | 41 | //====================================================================== 42 | // 43 | // nums8, 64x16@8, 44 | // + 16 tiles not compressed 45 | // Total size: 1024 = 1024 46 | // 47 | // Time-stamp: 2005-12-24, 14:35:11 48 | // Exported by Cearn's Usenti v1.7.1 49 | // (comments, kudos, flames to "daytshen@hotmail.com") 50 | // 51 | //====================================================================== 52 | 53 | #ifndef __NUMS8__ 54 | #define __NUMS8__ 55 | 56 | #define nums8TilesLen 1024 57 | extern const unsigned int nums8Tiles[256]; 58 | 59 | #endif // __NUMS8__ 60 | 61 | -------------------------------------------------------------------------------- /external/tonc/code/ext/win_demo/nums.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // nums, 64x16@4, 4 | // + palette 32 entries, not compressed 5 | // Total size: 64 = 64 6 | // 7 | // Time-stamp: 2005-12-24, 14:34:51 8 | // Exported by Cearn's Usenti v1.7.1 9 | // (comments, kudos, flames to "daytshen@hotmail.com") 10 | // 11 | //====================================================================== 12 | 13 | #ifndef __NUMS__ 14 | #define __NUMS__ 15 | 16 | #define numsPalLen 64 17 | extern const unsigned int numsPal[16]; 18 | 19 | #endif // __NUMS__ 20 | 21 | //====================================================================== 22 | // 23 | // nums4, 64x16@4, 24 | // + 16 tiles not compressed 25 | // Total size: 512 = 512 26 | // 27 | // Time-stamp: 2005-12-24, 14:35:00 28 | // Exported by Cearn's Usenti v1.7.1 29 | // (comments, kudos, flames to "daytshen@hotmail.com") 30 | // 31 | //====================================================================== 32 | 33 | #ifndef __NUMS4__ 34 | #define __NUMS4__ 35 | 36 | #define nums4TilesLen 512 37 | extern const unsigned int nums4Tiles[128]; 38 | 39 | #endif // __NUMS4__ 40 | 41 | //====================================================================== 42 | // 43 | // nums8, 64x16@8, 44 | // + 16 tiles not compressed 45 | // Total size: 1024 = 1024 46 | // 47 | // Time-stamp: 2005-12-24, 14:35:11 48 | // Exported by Cearn's Usenti v1.7.1 49 | // (comments, kudos, flames to "daytshen@hotmail.com") 50 | // 51 | //====================================================================== 52 | 53 | #ifndef __NUMS8__ 54 | #define __NUMS8__ 55 | 56 | #define nums8TilesLen 1024 57 | extern const unsigned int nums8Tiles[256]; 58 | 59 | #endif // __NUMS8__ 60 | 61 | -------------------------------------------------------------------------------- /external/tonc/code/basic/cbb_demo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # cbb_demo.mak 3 | # 4 | # makefile for tile-index tests 5 | # 6 | # NOTE: for educational purposes only. For real work, use 7 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 8 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 9 | 10 | PATH := $(DEVKITARM)/bin:$(PATH) 11 | 12 | # --- Project details ------------------------------------------------- 13 | 14 | PROJ := cbb_demo 15 | TITLE := $(PROJ) 16 | 17 | COBJS := $(PROJ).o cbb_ids.o 18 | 19 | OBJS := $(COBJS) 20 | 21 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 22 | 23 | MB = 0 24 | 25 | ifeq ($(MB),1) 26 | 27 | TARGET := $(PROJ).mb 28 | SPECS := -specs=gba_mb.specs 29 | 30 | else 31 | 32 | TARGET := $(PROJ) 33 | SPECS := -specs=gba.specs 34 | 35 | endif 36 | 37 | # --- Compiling ------------------------------------------------------- 38 | 39 | CROSS ?= arm-none-eabi- 40 | AS := $(CROSS)as 41 | CC := $(CROSS)gcc 42 | LD := $(CROSS)gcc 43 | OBJCOPY := $(CROSS)objcopy 44 | 45 | 46 | ARCH := -mthumb-interwork -mthumb 47 | 48 | ASFLAGS := -mthumb-interwork 49 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 50 | LDFLAGS := $(ARCH) $(SPECS) 51 | 52 | .PHONY : build clean 53 | 54 | # --- Build ----------------------------------------------------------- 55 | 56 | build : $(TARGET).gba 57 | 58 | 59 | $(TARGET).gba : $(TARGET).elf 60 | $(OBJCOPY) -v -O binary $< $@ 61 | -@gbafix $@ -t$(TITLE) 62 | 63 | $(TARGET).elf : $(OBJS) 64 | $(LD) $^ $(LDFLAGS) -o $@ 65 | 66 | $(COBJS) : %.o : %.c 67 | $(CC) $(CFLAGS) -c $< -o $@ 68 | 69 | # --- Clean ----------------------------------------------------------- 70 | 71 | clean : 72 | @rm -fv *.gba 73 | @rm -fv *.elf 74 | @rm -fv *.o 75 | 76 | #EOF 77 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/asm/tonc_nocash.s: -------------------------------------------------------------------------------- 1 | // 2 | // No$gba debugger messaging 3 | // 4 | //! \file tonc_nocash.s 5 | //! \author J Vijn 6 | //! \date 20080422 - 20080422 7 | 8 | #include "tonc_asminc.h" 9 | 10 | /* DECLARATIONS: 11 | int nocash_puts(const char *str); 12 | EWRAM_CODE void nocash_message(); 13 | extern EWRAM_DATA char nocash_buffer[80]; 14 | */ 15 | 16 | .global nocash_puts 17 | .global nocash_message 18 | .global nocash_buffer 19 | 20 | BEGIN_FUNC_THUMB(nocash_puts, CSEC_TEXT) 21 | push {r4, lr} 22 | ldr r4,=nocash_message @ Get messenger address 23 | ldr r1,=nocash_buffer @ Get buffer address 24 | 25 | mov r2, #0 26 | mov r12, r2 27 | 28 | @ Iterate over loop parts 29 | .Lmsg_loop: 30 | mov r2, #0 31 | 32 | @ Copy up to 80 chars and print 33 | .Lmsg_cpy: @ for(ii=0; ii<80; ii++) 34 | ldrb r3, [r0, r2] @ if((dst[ii]=src[ii]) == '\0') 35 | strb r3, [r1, r2] @ break; 36 | cmp r3, #0 37 | beq .Lmsg_print 38 | add r2, #1 39 | cmp r2, #80 40 | bne .Lmsg_cpy 41 | 42 | @ Print message 43 | .Lmsg_print: 44 | bl .Lmsg_far_call 45 | 46 | @ If not at end, continue with next part of string 47 | add r0, r2 48 | add r12, r2 49 | cmp r3, #0 50 | bne .Lmsg_loop 51 | 52 | @ Full string done. Set result and return 53 | mov r0, r12 54 | pop {r4} 55 | pop {r1} 56 | bx r1 57 | .Lmsg_far_call: 58 | bx r4 59 | END_FUNC(nocash_puts) 60 | 61 | BEGIN_FUNC_THUMB(nocash_message, CSEC_EWRAM) 62 | mov r12, r12 @ first ID 63 | b .Lmsg_end @ skip the text section 64 | .hword 0x6464 @ second ID 65 | .hword 0 @ flags 66 | nocash_buffer: 67 | .space 82 @ Message buffer 68 | 69 | .Lmsg_end: 70 | bx lr 71 | END_FUNC(nocash_message) 72 | 73 | @ EOF 74 | -------------------------------------------------------------------------------- /external/tonc/code/basic/brin_demo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # brin_demo.mak 3 | # 4 | # makefile for trivial map demo 5 | # 6 | # NOTE: for educational purposes only. For real work, use 7 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 8 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 9 | 10 | PATH := $(DEVKITARM)/bin:$(PATH) 11 | 12 | # --- Project details ------------------------------------------------- 13 | 14 | PROJ := brin_demo 15 | TITLE := $(PROJ) 16 | 17 | COBJS := $(PROJ).o brin.o toolbox.o 18 | 19 | OBJS := $(COBJS) 20 | 21 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 22 | 23 | MB = 0 24 | 25 | ifeq ($(MB),1) 26 | 27 | TARGET := $(PROJ).mb 28 | SPECS := -specs=gba_mb.specs 29 | 30 | else 31 | 32 | TARGET := $(PROJ) 33 | SPECS := -specs=gba.specs 34 | 35 | endif 36 | 37 | # --- Compiling ------------------------------------------------------- 38 | 39 | CROSS ?= arm-none-eabi- 40 | AS := $(CROSS)as 41 | CC := $(CROSS)gcc 42 | LD := $(CROSS)gcc 43 | OBJCOPY := $(CROSS)objcopy 44 | 45 | 46 | ARCH := -mthumb-interwork -mthumb 47 | 48 | ASFLAGS := -mthumb-interwork 49 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 50 | LDFLAGS := $(ARCH) $(SPECS) 51 | 52 | .PHONY : build clean 53 | 54 | # --- Build ----------------------------------------------------------- 55 | 56 | build : $(TARGET).gba 57 | 58 | 59 | $(TARGET).gba : $(TARGET).elf 60 | $(OBJCOPY) -v -O binary $< $@ 61 | -@gbafix $@ -t$(TITLE) 62 | 63 | $(TARGET).elf : $(OBJS) 64 | $(LD) $^ $(LDFLAGS) -o $@ 65 | 66 | $(COBJS) : %.o : %.c 67 | $(CC) $(CFLAGS) -c $< -o $@ 68 | 69 | # --- Clean ----------------------------------------------------------- 70 | 71 | clean : 72 | @rm -fv *.gba 73 | @rm -fv *.elf 74 | @rm -fv *.o 75 | 76 | #EOF 77 | -------------------------------------------------------------------------------- /external/tonc/code/basic/obj_demo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # obj_demo.mak 3 | # 4 | # Makefile for regular sprite demo 5 | # 6 | # NOTE: for educational purposes only. For real work, use 7 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 8 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 9 | 10 | PATH := $(DEVKITARM)/bin:$(PATH) 11 | 12 | # --- Project details ------------------------------------------------- 13 | 14 | PROJ := obj_demo 15 | TITLE := $(PROJ) 16 | 17 | COBJS := obj_demo.o toolbox.o metr.o 18 | 19 | OBJS := $(COBJS) 20 | 21 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 22 | 23 | MB = 0 24 | 25 | ifeq ($(MB),1) 26 | 27 | TARGET := $(PROJ).mb 28 | SPECS := -specs=gba_mb.specs 29 | 30 | else 31 | 32 | TARGET := $(PROJ) 33 | SPECS := -specs=gba.specs 34 | 35 | endif 36 | 37 | # --- Compiling ------------------------------------------------------- 38 | 39 | CROSS ?= arm-none-eabi- 40 | AS := $(CROSS)as 41 | CC := $(CROSS)gcc 42 | LD := $(CROSS)gcc 43 | OBJCOPY := $(CROSS)objcopy 44 | 45 | 46 | ARCH := -mthumb-interwork -mthumb 47 | 48 | ASFLAGS := -mthumb-interwork 49 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 50 | LDFLAGS := $(ARCH) $(SPECS) 51 | 52 | .PHONY : build clean 53 | 54 | # --- Build ----------------------------------------------------------- 55 | 56 | build : $(TARGET).gba 57 | 58 | 59 | $(TARGET).gba : $(TARGET).elf 60 | $(OBJCOPY) -v -O binary $< $@ 61 | -@gbafix $@ -t$(TITLE) 62 | 63 | $(TARGET).elf : $(OBJS) 64 | $(LD) $^ $(LDFLAGS) -o $@ 65 | 66 | $(COBJS) : %.o : %.c 67 | $(CC) $(CFLAGS) -c $< -o $@ 68 | 69 | # --- Clean ----------------------------------------------------------- 70 | 71 | clean : 72 | @rm -fv *.gba 73 | @rm -fv *.elf 74 | @rm -fv *.o 75 | 76 | #EOF 77 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tte/chr4c_drawg_b4cts.c: -------------------------------------------------------------------------------- 1 | // 2 | // Tile renderer, var width/height, 4bpp tiles, recolored with transparency 3 | // 4 | //! \file chr4c_drawg_b4cts.c 5 | //! \author J Vijn 6 | //! \date 20080427 - 20080427 7 | // 8 | // === NOTES === 9 | 10 | #include "tonc_memdef.h" 11 | #include "tonc_tte.h" 12 | 13 | 14 | // -------------------------------------------------------------------- 15 | // FUNCTIONS 16 | // -------------------------------------------------------------------- 17 | 18 | void chr4c_drawg_b4cts(uint gid) 19 | { 20 | TTE_BASE_VARS(tc, font); 21 | TTE_CHAR_VARS(font, gid, u32, srcD, srcL, charW, charH); 22 | uint x= tc->cursorX, y= tc->cursorY; 23 | uint srcP= font->cellH, dstP= tc->dst.pitch/4; 24 | 25 | u32 *dstD= (u32*)(tc->dst.data + y*4 + x/8*dstP*4), *dstL; 26 | x %= 8; 27 | u32 lsl= 4*x, lsr= 32-4*x, right= x+charW; 28 | 29 | // Inner loop vars 30 | u32 amask= 0x11111111; 31 | u32 px, pxmask, raw; 32 | u32 ink= tc->cattr[TTE_INK]; 33 | u32 shade= tc->cattr[TTE_SHADOW]; 34 | 35 | uint iy, iw; 36 | for(iw=0; iw>1 & amask); 48 | pxmask= px | raw; 49 | if(pxmask) 50 | { 51 | px *= ink; 52 | px += raw*shade; 53 | pxmask *= 15; 54 | 55 | // Write left tile: 56 | dstL[0] = (dstL[0] &~ (pxmask< 8) 60 | dstL[dstP]= (dstL[dstP] &~ (pxmask>>lsr) ) | (px>>lsr); 61 | } 62 | dstL++; 63 | } 64 | } 65 | } 66 | 67 | // EOF 68 | -------------------------------------------------------------------------------- /external/tonc/code/basic/key_demo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # key_demo.mak 3 | # 4 | # Makefile for key demonstration 5 | # 6 | # NOTE: for educational purposes only. For real work, use 7 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 8 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 9 | 10 | PATH := $(DEVKITARM)/bin:$(PATH) 11 | 12 | # --- Project details ------------------------------------------------- 13 | 14 | PROJ := key_demo 15 | TITLE := $(PROJ) 16 | 17 | COBJS := key_demo.o toolbox.o gba_pic.o 18 | 19 | OBJS := $(COBJS) 20 | 21 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 22 | 23 | MB = 0 24 | 25 | ifeq ($(MB),1) 26 | 27 | TARGET := $(PROJ).mb 28 | SPECS := -specs=gba_mb.specs 29 | 30 | else 31 | 32 | TARGET := $(PROJ) 33 | SPECS := -specs=gba.specs 34 | 35 | endif 36 | 37 | # --- Compiling ------------------------------------------------------- 38 | 39 | CROSS ?= arm-none-eabi- 40 | AS := $(CROSS)as 41 | CC := $(CROSS)gcc 42 | LD := $(CROSS)gcc 43 | OBJCOPY := $(CROSS)objcopy 44 | 45 | 46 | ARCH := -mthumb-interwork -mthumb 47 | 48 | ASFLAGS := -mthumb-interwork 49 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 50 | LDFLAGS := $(ARCH) $(SPECS) 51 | 52 | .PHONY : build clean 53 | 54 | # --- Build ----------------------------------------------------------- 55 | 56 | build : $(TARGET).gba 57 | 58 | 59 | $(TARGET).gba : $(TARGET).elf 60 | $(OBJCOPY) -v -O binary $< $@ 61 | -@gbafix $@ -t$(TITLE) 62 | 63 | $(TARGET).elf : $(OBJS) 64 | $(LD) $^ $(LDFLAGS) -o $@ 65 | 66 | $(COBJS) : %.o : %.c 67 | $(CC) $(CFLAGS) -c $< -o $@ 68 | 69 | # --- Clean ----------------------------------------------------------- 70 | 71 | clean : 72 | @rm -fv *.gba 73 | @rm -fv *.elf 74 | @rm -fv *.o 75 | 76 | #EOF 77 | -------------------------------------------------------------------------------- /external/tonc/code/basic/pageflip/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # pageflip.mak 3 | # 4 | # makefile for page flipping demo 5 | # 6 | # NOTE: for educational purposes only. For real work, use 7 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 8 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 9 | 10 | PATH := $(DEVKITARM)/bin:$(PATH) 11 | 12 | # --- Project details ------------------------------------------------- 13 | 14 | PROJ := pageflip 15 | TITLE := $(PROJ) 16 | 17 | COBJS := pageflip.o toolbox.o page_pic.o 18 | 19 | OBJS := $(COBJS) 20 | 21 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 22 | 23 | MB = 0 24 | 25 | ifeq ($(MB),1) 26 | 27 | TARGET := $(PROJ).mb 28 | SPECS := -specs=gba_mb.specs 29 | 30 | else 31 | 32 | TARGET := $(PROJ) 33 | SPECS := -specs=gba.specs 34 | 35 | endif 36 | 37 | # --- Compiling ------------------------------------------------------- 38 | 39 | CROSS ?= arm-none-eabi- 40 | AS := $(CROSS)as 41 | CC := $(CROSS)gcc 42 | LD := $(CROSS)gcc 43 | OBJCOPY := $(CROSS)objcopy 44 | 45 | 46 | ARCH := -mthumb-interwork -mthumb 47 | 48 | ASFLAGS := -mthumb-interwork 49 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 50 | LDFLAGS := $(ARCH) $(SPECS) 51 | 52 | .PHONY : build clean 53 | 54 | # --- Build ----------------------------------------------------------- 55 | 56 | build : $(TARGET).gba 57 | 58 | 59 | $(TARGET).gba : $(TARGET).elf 60 | $(OBJCOPY) -v -O binary $< $@ 61 | -@gbafix $@ -t$(TITLE) 62 | 63 | $(TARGET).elf : $(OBJS) 64 | $(LD) $^ $(LDFLAGS) -o $@ 65 | 66 | $(COBJS) : %.o : %.c 67 | $(CC) $(CFLAGS) -c $< -o $@ 68 | 69 | # --- Clean ----------------------------------------------------------- 70 | 71 | clean : 72 | @rm -fv *.gba 73 | @rm -fv *.elf 74 | @rm -fv *.o 75 | 76 | #EOF 77 | -------------------------------------------------------------------------------- /gba-core/build.rs: -------------------------------------------------------------------------------- 1 | use csv::Reader; 2 | 3 | const TEMPLATE: &str = r#"// This file is automatically generated from the GBA cartridge database CSV file. 4 | // Do not edit this file manually. 5 | 6 | use phf::phf_map; 7 | 8 | pub static TITLE_DATABASE: phf::Map<&'static str, (u8, bool, &'static str)> = phf_map! { 9 | $DB$ 10 | };"#; 11 | 12 | fn main() { 13 | let mut csv_reader = 14 | Reader::from_path("../external/titledb_mame.csv").expect("Failed to read GBA cartridge database CSV file"); 15 | 16 | let mut table = String::new(); 17 | 18 | for result in csv_reader.records().skip(1) { 19 | let record = result.expect("Failed to read record from CSV"); 20 | let crc32 = record 21 | .get(0) 22 | .unwrap_or_else(|| panic!("Missing crc32 in record: {:?}", record)); 23 | let backup_type = record 24 | .get(1) 25 | .unwrap_or_else(|| panic!("Missing backup_type in record: {:?}", record)); 26 | let has_rtc = record 27 | .get(2) 28 | .unwrap_or_else(|| panic!("Missing has_rtc in record: {:?}", record)); 29 | let game_title = record 30 | .get(3) 31 | .unwrap_or_else(|| panic!("Missing game_title in record: {:?}", record)); 32 | 33 | table.push_str(&format!( 34 | " \"{}\" => ({}, {}, r#\"{}\"#),\n", 35 | crc32, 36 | backup_type, 37 | if has_rtc == "1" { "true" } else { "false" }, 38 | game_title 39 | )); 40 | } 41 | 42 | let output = TEMPLATE.replace("$DB$", &table); 43 | std::fs::write("src/cartridge/database.rs", output).expect("Failed to write cartridge database source file"); 44 | 45 | println!("cargo:rerun-if-changed=../external/titledb_mame.csv"); 46 | } 47 | -------------------------------------------------------------------------------- /external/tonc/code/basic/sbb_reg/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # sbb_reg.mak 3 | # 4 | # Shows how multiple screenblocks are used for larger sized 5 | # regular backgrounds. 6 | # 7 | # NOTE: for educational purposes only. For real work, use 8 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 9 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 10 | 11 | PATH := $(DEVKITARM)/bin:$(PATH) 12 | 13 | # --- Project details ------------------------------------------------- 14 | 15 | PROJ := sbb_reg 16 | TITLE := $(PROJ) 17 | 18 | COBJS := $(PROJ).o toolbox.o 19 | 20 | OBJS := $(COBJS) 21 | 22 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 23 | 24 | MB = 0 25 | 26 | ifeq ($(MB),1) 27 | 28 | TARGET := $(PROJ).mb 29 | SPECS := -specs=gba_mb.specs 30 | 31 | else 32 | 33 | TARGET := $(PROJ) 34 | SPECS := -specs=gba.specs 35 | 36 | endif 37 | 38 | # --- Compiling ------------------------------------------------------- 39 | 40 | CROSS ?= arm-none-eabi- 41 | AS := $(CROSS)as 42 | CC := $(CROSS)gcc 43 | LD := $(CROSS)gcc 44 | OBJCOPY := $(CROSS)objcopy 45 | 46 | 47 | ARCH := -mthumb-interwork -mthumb 48 | 49 | ASFLAGS := -mthumb-interwork 50 | CFLAGS := $(ARCH) -O2 -Wall -fno-strict-aliasing 51 | LDFLAGS := $(ARCH) $(SPECS) 52 | 53 | .PHONY : build clean 54 | 55 | # --- Build ----------------------------------------------------------- 56 | 57 | build : $(TARGET).gba 58 | 59 | 60 | $(TARGET).gba : $(TARGET).elf 61 | $(OBJCOPY) -v -O binary $< $@ 62 | -@gbafix $@ -t$(TITLE) 63 | 64 | $(TARGET).elf : $(OBJS) 65 | $(LD) $^ $(LDFLAGS) -o $@ 66 | 67 | $(COBJS) : %.o : %.c 68 | $(CC) $(CFLAGS) -c $< -o $@ 69 | 70 | # --- Clean ----------------------------------------------------------- 71 | 72 | clean : 73 | @rm -fv *.gba 74 | @rm -fv *.elf 75 | @rm -fv *.o 76 | 77 | #EOF 78 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tte/bmp16_drawg.c: -------------------------------------------------------------------------------- 1 | // 2 | // Bitmap 16bpp glyph renderers 3 | // 4 | //! \file bmp16_drawg.c 5 | //! \author J Vijn 6 | //! \date 20080311 - 20080311 7 | // 8 | // === NOTES === 9 | 10 | #include "tonc_memdef.h" 11 | 12 | #include "tonc_tte.h" 13 | 14 | // -------------------------------------------------------------------- 15 | // FUNCTIONS 16 | // -------------------------------------------------------------------- 17 | 18 | 19 | //! Linear 16bpp bitmap glyph renderer, opaque. 20 | /* Works on a 16 bpp bitmap 21 | \param gid Character to plot. 22 | \note Font params: bitmapped, 16bpp. 23 | */ 24 | void bmp16_drawg(uint gid) 25 | { 26 | TTE_BASE_VARS(tc, font); 27 | TTE_CHAR_VARS(font, gid, u16, srcD, srcL, charW, charH); 28 | TTE_DST_VARS(tc, u16, dstD, dstL, dstP, x0, y0); 29 | uint srcP= font->cellW; 30 | dstL= &dstD[x0]; 31 | 32 | // The actual rendering 33 | uint ix, iy; 34 | for(iy=0; iycellW; 55 | dstL= &dstD[x0]; 56 | 57 | u32 trans= tc->cattr[TTE_SPECIAL]; 58 | 59 | // The actual rendering 60 | uint ix, iy; 61 | for(iy=0; iycursorX, y0= tc->cursorY; 30 | uint srcP= font->cellW; 31 | 32 | // The actual rendering. 33 | uint ix, iy; 34 | for(iy=0; iydst, x0+ix, y0+iy, srcL[ix]); 39 | 40 | srcL += srcP; 41 | } 42 | } 43 | 44 | //! Linear 8 bpp bitmap glyph renderer, transparent. 45 | /* Works on a 8 bpp bitmap 46 | \param gid Character to plot. 47 | \note Font params: bitmapped, 8bpp. special cattr is transparent. 48 | \note UNTESTED 49 | */ 50 | void bmp8_drawg_t(uint gid) 51 | { 52 | TTE_BASE_VARS(tc, font); 53 | TTE_CHAR_VARS(font, gid, u8, srcD, srcL, charW, charH); 54 | uint x0= tc->cursorX, y0= tc->cursorY; 55 | uint srcP= font->cellW; 56 | 57 | u32 trans= tc->cattr[TTE_SPECIAL]; 58 | 59 | // The actual rendering. 60 | uint ix, iy; 61 | for(iy=0; iydst, x0+ix, y0+iy, srcL[ix]); 66 | 67 | srcL += srcP; 68 | } 69 | } 70 | 71 | // EOF 72 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/pre1.3/tonc_text.c: -------------------------------------------------------------------------------- 1 | // 2 | // Text system file 3 | // 4 | //! \file tonc_text.c 5 | //! \author J Vijn 6 | //! \date 20060605 - 20060605 7 | // 8 | // === NOTES === 9 | // * Since BitUnPack doesn't always work properly (VBA), I've put 10 | // txt_bup_1toX in here to remedy that. Wish I didn't have to. 11 | 12 | #include "tonc_text.h" 13 | 14 | 15 | // -------------------------------------------------------------------- 16 | // GLOBALS 17 | // -------------------------------------------------------------------- 18 | 19 | 20 | u8 txt_lut[256]; 21 | 22 | TXT_BASE __txt_base; 23 | TXT_BASE *gptxt= &__txt_base; 24 | 25 | 26 | // -------------------------------------------------------------------- 27 | // FUNCTIONS 28 | // -------------------------------------------------------------------- 29 | 30 | 31 | void txt_init_std() 32 | { 33 | gptxt->dx= gptxt->dy= 8; 34 | 35 | gptxt->dst0= vid_mem; 36 | gptxt->font= (u32*)toncfontTiles; 37 | gptxt->chars= txt_lut; 38 | gptxt->cws= NULL; 39 | 40 | int ii; 41 | for(ii=0; ii<96; ii++) 42 | gptxt->chars[ii+32]= ii; 43 | } 44 | 45 | void txt_bup_1toX(void *dstv, const void *srcv, u32 len, int dstB, u32 base) 46 | { 47 | u32 *srcL= (u32*)srcv; 48 | u32 *dstL= (u32*)dstv; 49 | 50 | len= (len*dstB+3)>>2; // # dst words 51 | u32 bBase0= base&(1<<31); // add to 0 too? 52 | base &= ~(1<<31); 53 | 54 | 55 | u32 srcBuf=0, srcShift=32; 56 | u32 dstBuf , dstShift; 57 | 58 | while(len--) 59 | { 60 | if(srcShift >= 32) 61 | { 62 | srcBuf= *srcL++; 63 | srcShift= 0; 64 | } 65 | dstBuf=0; 66 | for(dstShift=0; dstShift<32; dstShift += dstB) 67 | { 68 | u32 wd= srcBuf&1; 69 | if(wd || bBase0) 70 | wd += base; 71 | dstBuf |= wd<>= 1; 74 | srcShift++; 75 | } 76 | 77 | *dstL++= dstBuf; 78 | } 79 | } 80 | 81 | // EOF 82 | -------------------------------------------------------------------------------- /rom-db-ui/app/page.tsx: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | import SearchComponent from './SearchComponent'; 4 | 5 | function getScreenshotFolders() { 6 | try { 7 | const screenshotsPath = path.resolve(process.cwd(), 'public/screenshots/'); 8 | 9 | if (!fs.existsSync(screenshotsPath)) { 10 | console.error('Screenshots directory not found'); 11 | return []; 12 | } 13 | 14 | const entries = fs.readdirSync(screenshotsPath, { withFileTypes: true }); 15 | 16 | return entries 17 | .filter(entry => entry.isDirectory()) 18 | .map(dir => dir.name); 19 | 20 | } catch (error) { 21 | console.error('Error fetching screenshot folders:', error); 22 | return []; 23 | } 24 | } 25 | 26 | function getImagesInFolder(folderName: string) { 27 | try { 28 | const folderPath = path.resolve(process.cwd(), 'public/screenshots/', folderName); 29 | const entries = fs.readdirSync(folderPath); 30 | 31 | // only include .png files 32 | const filteredEntries = entries.filter(file => file.toLowerCase().endsWith('.png')); 33 | 34 | // sort by filename (number) 35 | filteredEntries.sort((a, b) => parseInt(a) - parseInt(b)); 36 | 37 | return filteredEntries; 38 | } catch (error) { 39 | console.error(`Error reading images from folder ${folderName}:`, error); 40 | return []; 41 | } 42 | } 43 | 44 | export default function ScreenshotsPage() { 45 | const folders = getScreenshotFolders(); 46 | 47 | const folderImages = folders.map(folder => { 48 | const images = getImagesInFolder(folder); 49 | return { folder, images }; 50 | }); 51 | 52 | return ( 53 |
54 | 55 |
56 | ); 57 | } 58 | -------------------------------------------------------------------------------- /external/tonc/code/basic/hello/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # hello.mak 3 | # 4 | # tilemap text via tonclib 5 | # 6 | # NOTE: for educational purposes only. For real work, use 7 | # devkitPro's templates ( $(DEVKITPRO)/examples/gba/template ) 8 | # or tonclib's templates ( $(TONCCODE)/lab/template ) 9 | 10 | PATH := $(DEVKITARM)/bin:$(PATH) 11 | 12 | # --- Project details ------------------------------------------------- 13 | 14 | PROJ := hello 15 | TITLE := $(PROJ) 16 | 17 | LIBTONC := ../../tonclib 18 | 19 | INCLUDE := -I$(LIBTONC)/include 20 | LIBPATHS := -L$(LIBTONC)/lib 21 | 22 | LIBS := -ltonc 23 | 24 | COBJS := $(PROJ).o 25 | 26 | OBJS := $(COBJS) 27 | 28 | # --- boot type (MB=0 : normal. MB=1 : multiboot) --- 29 | 30 | MB = 0 31 | 32 | ifeq ($(MB),1) 33 | 34 | TARGET := $(PROJ).mb 35 | SPECS := -specs=gba_mb.specs 36 | 37 | else 38 | 39 | TARGET := $(PROJ) 40 | SPECS := -specs=gba.specs 41 | 42 | endif 43 | 44 | # --- Compiling ------------------------------------------------------- 45 | 46 | CROSS ?= arm-none-eabi- 47 | AS := $(CROSS)as 48 | CC := $(CROSS)gcc 49 | LD := $(CROSS)gcc 50 | OBJCOPY := $(CROSS)objcopy 51 | 52 | 53 | ARCH := -mthumb-interwork -mthumb 54 | 55 | ASFLAGS := -mthumb-interwork 56 | CFLAGS := $(ARCH) $(INCLUDE) -O2 -Wall -fno-strict-aliasing 57 | LDFLAGS := $(ARCH) $(SPECS) $(LIBPATHS) $(LIBS) -Wl,-Map,$(PROJ).map 58 | 59 | .PHONY : build clean 60 | 61 | # --- Build ----------------------------------------------------------- 62 | 63 | build : $(TARGET).gba 64 | 65 | 66 | $(TARGET).gba : $(TARGET).elf 67 | $(OBJCOPY) -v -O binary $< $@ 68 | -@gbafix $@ -t$(TITLE) 69 | 70 | $(TARGET).elf : $(OBJS) 71 | $(LD) $^ $(LDFLAGS) -o $@ 72 | 73 | $(COBJS) : %.o : %.c 74 | $(CC) $(CFLAGS) -c $< -o $@ 75 | 76 | # --- Clean ----------------------------------------------------------- 77 | 78 | clean : 79 | @rm -fv *.gba 80 | @rm -fv *.elf 81 | @rm -fv *.o 82 | 83 | #EOF 84 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/include/tonc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Main tonc header 3 | // 4 | //! \file tonc.h 5 | //! \author J Vijn 6 | //! \date 20060508 - 20080825 7 | // 8 | // === NOTES === 9 | 10 | 11 | #ifndef TONC_MAIN 12 | #define TONC_MAIN 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "tonc_types.h" 19 | #include "tonc_memmap.h" 20 | #include "tonc_memdef.h" 21 | 22 | #include "tonc_bios.h" 23 | #include "tonc_core.h" 24 | #include "tonc_input.h" 25 | #include "tonc_irq.h" 26 | #include "tonc_math.h" 27 | #include "tonc_oam.h" 28 | #include "tonc_tte.h" 29 | #include "tonc_video.h" 30 | #include "tonc_surface.h" 31 | 32 | #include "tonc_nocash.h" 33 | 34 | // For old times' sake 35 | #include "tonc_text.h" 36 | 37 | #ifdef __cplusplus 38 | }; 39 | #endif 40 | 41 | // --- Doxygen modules: --- 42 | 43 | /*! \defgroup grpBios Bios Calls */ 44 | /*! \defgroup grpCore Core */ 45 | /*! \defgroup grpDma DMA */ 46 | /*! \defgroup grpInput Input */ 47 | /*! \defgroup grpIrq Interrupt */ 48 | /*! \defgroup grpMath Math */ 49 | /*! \defgroup grpMemmap Memory Map */ 50 | /*! \defgroup grpAudio Sound */ 51 | /*! \defgroup grpTTE Tonc Text Engine */ 52 | /*! \defgroup grpText Old Text */ 53 | /*! \defgroup grpTimer Timer */ 54 | /*! \defgroup grpVideo Video */ 55 | 56 | 57 | 58 | /*! \mainpage Tonclib 1.4 (20080825) 59 |

60 | Tonclib is the library accompanying the set of GBA tutorials known 61 | as Tonc Initially, it 62 | was just a handful of macros and functions for dealing with the 63 | GBA hardware: the memory map and its bits, affine transformation 64 | code and things like that. More recently, more general items 65 | have been added like tonccpy() and toncset(), the TSurface system 66 | and TTE. All these items should provide a firm basis on which to 67 | build GBA software. 68 |

69 | */ 70 | 71 | #endif // TONC_MAIN 72 | 73 | -------------------------------------------------------------------------------- /external/tonc/code/lab/template/gba-tonc-fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Converts names from template to project-specific stuff, based on the 4 | # directory name. Changes minor things in Makefile and PN2 project files. 5 | # 6 | # Usage : 7 | # - Copy template folder. 8 | # - Rename folder. 9 | # - Run script. This file will also remove itself once you're done. 10 | # 11 | # 'Pre-usage' considerations: 12 | # - Set the library paths to point to the right folders on your system. 13 | 14 | # --------------------------------------------------------------------- 15 | # Variables 16 | # --------------------------------------------------------------------- 17 | 18 | files="template.pnproj template.ppg Makefile" 19 | projdir=$(dirname $0) 20 | proj=$(basename $projdir) 21 | 22 | 23 | # Full path of the library itself, in platform-specific format. 24 | # Yeah, it's ugly, but apparently the only way to get it right. 25 | libtonc=e:/dev/gba/proj/tonc/code/tonclib 26 | 27 | # Replacement list, space separated. 28 | sedlist="PROJNAME=$proj LIBTONC=$libtonc" 29 | 30 | # --------------------------------------------------------------------- 31 | # Actual script 32 | # --------------------------------------------------------------------- 33 | 34 | # Construct sed-script for conversions. 35 | for item in $sedlist ; do 36 | sedcmd="$sedcmd -e s#\[\[${item/=/\]\]#}#g" 37 | done 38 | 39 | # Apply conversions for appropriate files. 40 | # NOTE: if I don't do this by using an intermediate file, things go squirrily. 41 | for file in $files 42 | do 43 | if [ -e $file ] ; then 44 | echo Converting: $file 45 | dst=${file/template/$proj} # Filename conversion. 46 | sed $sedcmd $file > $dst.t # File content conversion. 47 | rm -f $file 48 | mv $dst.t $dst 49 | fi 50 | done 51 | 52 | # Remove this script if not in the template directory. 53 | if [ "$proj" != "template" ] && [ "$proj" != "nds-forge" ] ; then 54 | echo "This file will self-destruct in 3 ... 2 ... 1 ..." 55 | rm -f $0 56 | fi 57 | -------------------------------------------------------------------------------- /external/tonc/code/basic/second/toolbox.h: -------------------------------------------------------------------------------- 1 | // toolbox.h: 2 | // 3 | // Tools header for second.c 4 | // 5 | // (20060211-20060922, cearn) 6 | // 7 | // === NOTES === 8 | // * This is a _small_ set of typedefs, #defines and inlines that can 9 | // be found in tonclib, and might not represent the 10 | // final forms. 11 | 12 | 13 | #ifndef TOOLBOX_H 14 | #define TOOLBOX_H 15 | 16 | // === (from tonc_types.h) ============================================ 17 | 18 | typedef unsigned char u8; 19 | typedef unsigned short u16; 20 | typedef unsigned int u32; 21 | 22 | typedef u16 COLOR; 23 | 24 | #define INLINE static inline 25 | 26 | // === (from tonc_memmap.h) =========================================== 27 | 28 | #define MEM_IO 0x04000000 29 | #define MEM_VRAM 0x06000000 30 | 31 | #define REG_DISPCNT *((u32*)(MEM_IO+0x0000)) 32 | 33 | // === (from tonc_memdef.h) =======================================---- 34 | 35 | // --- REG_DISPCNT defines --- 36 | #define DCNT_MODE0 0x0000 37 | #define DCNT_MODE1 0x0001 38 | #define DCNT_MODE2 0x0002 39 | #define DCNT_MODE3 0x0003 40 | #define DCNT_MODE4 0x0004 41 | #define DCNT_MODE5 0x0005 42 | // layers 43 | #define DCNT_BG0 0x0100 44 | #define DCNT_BG1 0x0200 45 | #define DCNT_BG2 0x0400 46 | #define DCNT_BG3 0x0800 47 | #define DCNT_OBJ 0x1000 48 | 49 | 50 | // === (from tonc_video.h) ============================================ 51 | 52 | #define SCREEN_WIDTH 240 53 | #define SCREEN_HEIGHT 160 54 | 55 | #define vid_mem ((u16*)MEM_VRAM) 56 | 57 | INLINE void m3_plot(int x, int y, COLOR clr) 58 | { vid_mem[y*SCREEN_WIDTH+x]= clr; } 59 | 60 | #define CLR_BLACK 0x0000 61 | #define CLR_RED 0x001F 62 | #define CLR_LIME 0x03E0 63 | #define CLR_YELLOW 0x03FF 64 | #define CLR_BLUE 0x7C00 65 | #define CLR_MAG 0x7C1F 66 | #define CLR_CYAN 0x7FE0 67 | #define CLR_WHITE 0x7FFF 68 | 69 | 70 | INLINE COLOR RGB15(u32 red, u32 green, u32 blue) 71 | { return red | (green<<5) | (blue<<10); } 72 | 73 | #endif // TOOLBOX_H 74 | 75 | // EOF 76 | -------------------------------------------------------------------------------- /gba-core/src/arm7tdmi/pipeline.rs: -------------------------------------------------------------------------------- 1 | use super::decoder::Instruction; 2 | use crate::memory::mmio::Mmio; 3 | use std::fmt::Display; 4 | use tracing::*; 5 | 6 | pub struct State { 7 | pub pc: u32, 8 | pub opcode: u32, 9 | pub is_thumb: bool, 10 | } 11 | 12 | pub struct Pipeline { 13 | states: Vec, 14 | } 15 | 16 | impl Pipeline { 17 | pub fn new() -> Pipeline { 18 | Pipeline { 19 | states: Vec::with_capacity(3), 20 | } 21 | } 22 | 23 | pub fn advance(&mut self, pc: u32, is_thumb: bool, mmio: &mut Mmio) { 24 | let opcode = mmio.read_u32(pc); 25 | self.states.push(State { pc, opcode, is_thumb }); 26 | } 27 | 28 | pub fn pop(&mut self) -> Option<(Instruction, State)> { 29 | if self.states.len() < 3 { 30 | return None; 31 | } 32 | 33 | let state = self.states.remove(0); 34 | let instr = Instruction::decode(state.opcode, state.is_thumb).unwrap_or_else(|e| { 35 | error!(target: "pipeline", "Failed to decode instruction: {:?} at {:08X}", e, state.pc); 36 | Instruction::nop() 37 | }); 38 | 39 | Some((instr, state)) 40 | } 41 | 42 | pub fn flush(&mut self) { 43 | self.states.clear(); 44 | } 45 | 46 | pub fn peek_fetch(&self) -> Option<&State> { 47 | self.states.last() 48 | } 49 | 50 | pub fn is_full(&self) -> bool { 51 | self.states.len() >= 3 52 | } 53 | 54 | pub fn is_empty(&self) -> bool { 55 | self.states.is_empty() 56 | } 57 | } 58 | 59 | impl Display for Pipeline { 60 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 61 | write!(f, "Pipeline: [")?; 62 | for (i, state) in self.states.iter().enumerate() { 63 | if i > 0 { 64 | write!(f, ", ")?; 65 | } 66 | write!(f, "{:08X} @ {:08X}", state.opcode, state.pc)?; 67 | } 68 | write!(f, "]") 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /external/tonc/code/adv/m7_ex/source/id_sort_shell.s: -------------------------------------------------------------------------------- 1 | @ 2 | @ id_sort_shell2: general shellsort unsing an index table 3 | @ MAXCOUNT: 256 4 | @ === NOTES: === 5 | @ * changed from oe->fill keys to int keys after completion; 6 | @ not fully optimised for that yet. 7 | 8 | .section .iwram,"ax",%progbits 9 | .align 2 10 | @ DECL: CODE_IN_IWRAM void id_sort_shell(int keys[], u8 ids[], int count) 11 | @ r0: sort key (oe.fill) 12 | @ r1: sort indices 13 | @ r2: array length 14 | @ r3: inc 15 | @ r4, r5, r6: inc, ii, jj, jj-inc 16 | @ r7: id= ids[jj-inc] 17 | @ r8, r9: id0=ids[ii], key0=fill[ids[ii]] 18 | @ r10: fill[id] 19 | @ r12: (1<<32)/3 20 | .global id_sort_shell 21 | id_sort_shell: 22 | stmfd sp!, {r4-r10} 23 | @ TODO: special for count==1 24 | @ setup inc: inc= 3*inc+1 25 | mov r3, #0 26 | .Lshell_inc_setup: 27 | rsb r3, r3, r3, lsl #2 28 | add r3, r3, #1 29 | cmp r3, r2 30 | ble .Lshell_inc_setup 31 | ldr r12, .Lshell_pool 32 | @ inc loop 33 | .Lshell_inc_loop: 34 | umull r5, r4, r12, r3 @ ii= inc/3 35 | mov r3, r4 @ inc= ii 36 | cmp r3, r2 @ ii>count 37 | bgt .Lshell_up_loop_end 38 | @ ii=inc to nn loop 39 | .Lshell_up_loop: 40 | ldrb r8, [r1, r4] @ id0= ids[ii] 41 | ldr r9, [r0, r8, lsl #2] @ key0= fill[ids[ii]] 42 | mov r5, r4 @ jj= ii 43 | sub r6, r5, r3 @ jnext= jj-inc 44 | @ jj=ii to 0 loop 45 | .Lshell_down_loop: 46 | ldrb r7, [r1, r6] 47 | ldr r10, [r0, r7, lsl #2] 48 | cmp r10, r9 @ fill[id] > key0 49 | ble .Lshell_down_loop_end 50 | strb r7, [r1, r5] @ PONDER: xxxgt? 51 | mov r5, r6 52 | subs r6, r5, r3 53 | bge .Lshell_down_loop 54 | .Lshell_down_loop_end: 55 | strb r8, [r1, r5] @ TODO: clean 56 | add r4, r4, #1 @ TODO: combine with ldrb 57 | cmp r4, r2 58 | blt .Lshell_up_loop 59 | .Lshell_up_loop_end: 60 | cmp r3, #1 61 | bgt .Lshell_inc_loop 62 | ldmfd sp!, {r4-r10} 63 | bx lr 64 | .align 2 65 | .Lshell_pool: 66 | .word 1431655766 67 | 68 | -------------------------------------------------------------------------------- /external/tonc/code/lab/prio_demo/id_sort_shell2.s: -------------------------------------------------------------------------------- 1 | @ 2 | @ id_sort_shell2: general shellsort unsing an index table 3 | @ MAXCOUNT: 256 4 | @ === NOTES: === 5 | @ * changed from oe->fill keys to int keys after completion; 6 | @ not fully optimised for that yet. 7 | 8 | .section .iwram,"ax",%progbits 9 | .align 2 10 | @ DECL: CODE_IN_IWRAM void id_sort_shell2(int keys[], u8 ids[], int count) 11 | @ r0: sort key (oe.fill) 12 | @ r1: sort indices 13 | @ r2: array length 14 | @ r3: inc 15 | @ r4, r5, r6: inc, ii, jj, jj-inc 16 | @ r7: id= ids[jj-inc] 17 | @ r8, r9: id0=ids[ii], key0=fill[ids[ii]] 18 | @ r10: fill[id] 19 | @ r12: (1<<32)/3 20 | .global id_sort_shell2 21 | id_sort_shell2: 22 | stmfd sp!, {r4-r10} 23 | @ TODO: special for count==1 24 | @ setup inc: inc= 3*inc+1 25 | mov r3, #0 26 | .Lshell_inc_setup: 27 | rsb r3, r3, r3, lsl #2 28 | add r3, r3, #1 29 | cmp r3, r2 30 | ble .Lshell_inc_setup 31 | ldr r12, .Lshell_pool 32 | @ inc loop 33 | .Lshell_inc_loop: 34 | umull r5, r4, r12, r3 @ ii= inc/3 35 | mov r3, r4 @ inc= ii 36 | cmp r3, r2 @ ii>count 37 | bgt .Lshell_up_loop_end 38 | @ ii=inc to nn loop 39 | .Lshell_up_loop: 40 | ldrb r8, [r1, r4] @ id0= ids[ii] 41 | ldr r9, [r0, r8, lsl #2] @ key0= fill[ids[ii]] 42 | mov r5, r4 @ jj= ii 43 | sub r6, r5, r3 @ jnext= jj-inc 44 | @ jj=ii to 0 loop 45 | .Lshell_down_loop: 46 | ldrb r7, [r1, r6] 47 | ldr r10, [r0, r7, lsl #2] 48 | cmp r10, r9 @ fill[id] > key0 49 | ble .Lshell_down_loop_end 50 | strb r7, [r1, r5] @ PONDER: xxxgt? 51 | mov r5, r6 52 | subs r6, r5, r3 53 | bge .Lshell_down_loop 54 | .Lshell_down_loop_end: 55 | strb r8, [r1, r5] @ TODO: clean 56 | add r4, r4, #1 @ TODO: combine with ldrb 57 | cmp r4, r2 58 | blt .Lshell_up_loop 59 | .Lshell_up_loop_end: 60 | cmp r3, #1 61 | bgt .Lshell_inc_loop 62 | ldmfd sp!, {r4-r10} 63 | bx lr 64 | .align 2 65 | .Lshell_pool: 66 | .word 1431655766 67 | 68 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tte/chr4c_drawg_b1cts.c: -------------------------------------------------------------------------------- 1 | // 2 | // Tile renderer, var width/height, 1->4bpp tiles, 3 | // recolored with transparency 4 | // 5 | //! \file chr4c_drawg_b1cts.c 6 | //! \author J Vijn 7 | //! \date 20070621 - 20080427 8 | // 9 | /* === NOTES === 10 | * 20070725: Skipping rendering if raw == 0 helps. A lot. Also, there 11 | is more than one way to bitunpack and split between tiles. Which 12 | method is faster is very platform dependent. 13 | * 20070723: Prepping dst stuff inside the drawg and passing along to 14 | renc does NOT help (prolly due to Thumb). Try combining in 15 | asm manually. 16 | */ 17 | 18 | #include "tonc_memdef.h" 19 | #include "tonc_tte.h" 20 | 21 | 22 | // -------------------------------------------------------------------- 23 | // FUNCTIONS 24 | // -------------------------------------------------------------------- 25 | 26 | //! Render 1bpp fonts to 4bpp tiles 27 | void chr4c_drawg_b1cts(uint gid) 28 | { 29 | TTE_BASE_VARS(tc, font); 30 | TTE_CHAR_VARS(font, gid, u8, srcD, srcL, charW, charH); 31 | uint x= tc->cursorX, y= tc->cursorY; 32 | uint srcP= font->cellH, dstP= tc->dst.pitch/4; 33 | 34 | u32 *dstD= (u32*)(tc->dst.data + y*4 + x/8*dstP*4), *dstL; 35 | x %= 8; 36 | u32 lsl= 4*x, lsr= 32-4*x, right= x+charW; 37 | 38 | // Inner loop vars 39 | u32 px, pxmask, raw; 40 | u32 ink= tc->cattr[TTE_INK]; 41 | const u32 mask= 0x01010101; 42 | 43 | uint iy, iw; 44 | for(iw=0; iw 8) 69 | dstL[dstP]= (dstL[dstP] &~ (pxmask>>lsr) ) | (px>>lsr); 70 | } 71 | dstL++; 72 | } 73 | } 74 | } 75 | 76 | // EOF 77 | -------------------------------------------------------------------------------- /gba-core/src/cartridge/sram.rs: -------------------------------------------------------------------------------- 1 | use tracing::debug; 2 | 3 | use crate::cartridge::StorageChip; 4 | use crate::cartridge::storage::BackupType; 5 | use crate::memory::device::{Addressable, Saveable}; 6 | 7 | const SRAM_SIZE: u32 = 0x8000; // 32 KiB 8 | 9 | pub struct Sram { 10 | sram: Vec, 11 | backup_type: BackupType, 12 | } 13 | 14 | impl Sram { 15 | pub fn new() -> Self { 16 | Sram { 17 | sram: vec![0; SRAM_SIZE as usize], 18 | backup_type: BackupType::Sram, 19 | } 20 | } 21 | } 22 | 23 | impl Addressable for Sram { 24 | fn read(&self, addr: u32) -> u8 { 25 | match addr { 26 | 0x0E000000..=0x0FFFFFFF => { 27 | // GamePak SRAM – mirrors every 32 KiB in 0x0E000000‑0x0FFFFFFF 28 | let addr = (addr - 0x0E000000) % SRAM_SIZE; 29 | self.sram[addr as usize] 30 | } 31 | _ => unreachable!(), 32 | } 33 | } 34 | 35 | fn write(&mut self, addr: u32, value: u8) { 36 | match addr { 37 | 0x0E000000..=0x0FFFFFFF => { 38 | // GamePak SRAM – mirrors every 32 KiB in 0x0E000000‑0x0FFFFFFF 39 | let addr = (addr - 0x0E000000) % SRAM_SIZE; 40 | self.sram[addr as usize] = value; 41 | } 42 | _ => unreachable!(), 43 | } 44 | } 45 | } 46 | 47 | impl StorageChip for Sram { 48 | fn size(&self) -> usize { 49 | SRAM_SIZE as usize 50 | } 51 | 52 | fn backup_type(&self) -> BackupType { 53 | self.backup_type 54 | } 55 | 56 | fn backing_storage(&self) -> Vec { 57 | self.sram.clone() 58 | } 59 | } 60 | 61 | impl Saveable for Sram { 62 | fn aggregate_storage(&self) -> Vec { 63 | self.sram.clone() 64 | } 65 | 66 | fn load_storage(&mut self, data: &[u8]) { 67 | if data.len() != SRAM_SIZE as usize { 68 | panic!("Invalid SRAM data size: expected {}, got {}", SRAM_SIZE, data.len()); 69 | } 70 | 71 | debug!(target: "storage", "Loading SRAM with {} bytes", data.len()); 72 | self.sram.copy_from_slice(data); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /scripts/dump_swi.rhai: -------------------------------------------------------------------------------- 1 | fn dump_bios_function() { 2 | let BIOS_FUNC_LUT = #{ 3 | "0x00": "SoftReset", 4 | "0x01": "RegisterRamReset", 5 | "0x02": "Halt", 6 | "0x03": "Stop/Sleep", 7 | "0x04": "IntrWait", 8 | "0x05": "VBlankIntrWait", 9 | "0x06": "Div", 10 | "0x07": "DivArm", 11 | "0x08": "Sqrt", 12 | "0x09": "ArcTan", 13 | "0x0a": "ArcTan2", 14 | "0x0b": "CpuSet", 15 | "0x0c": "CpuFastSet", 16 | "0x0d": "GetBiosChecksum", 17 | "0x0e": "BgAffineSet", 18 | "0x0f": "ObjAffineSet", 19 | "0x10": "BitUnPack", 20 | "0x11": "LZ77UnCompWram", 21 | "0x12": "LZ77UnCompVram", 22 | "0x13": "HuffUnComp", 23 | "0x14": "RLUnCompWram", 24 | "0x15": "RLUnCompVram", 25 | "0x16": "Diff8bitUnFilterWram", 26 | "0x17": "Diff8bitUnFilterVram", 27 | "0x18": "Diff16bitUnFilter", 28 | "0x19": "SoundBias", 29 | "0x1a": "SoundDriverInit", 30 | "0x1b": "SoundDriverMode", 31 | "0x1c": "SoundDriverMain", 32 | "0x1d": "SoundDriverVSync", 33 | "0x1e": "SoundChannelClear", 34 | "0x1f": "MidiKey2Freq", 35 | "0x20": "SoundWhatever0", 36 | "0x21": "SoundWhatever1", 37 | "0x22": "SoundWhatever2", 38 | "0x23": "SoundWhatever3", 39 | "0x24": "SoundWhatever4", 40 | "0x25": "MultiBoot", 41 | "0x26": "HardReset", 42 | "0x27": "CustomHalt", 43 | "0x28": "SoundDriverVSyncOff", 44 | "0x29": "SoundDriverVSyncOn", 45 | "0x2a": "SoundGetJumpList", 46 | }; 47 | 48 | let r12 = emu.read_register("r12"); // LDRB R12, [LR, -#$0002] 49 | let bios_func = `0x${hex8(emu.read_u8(r12))}`; 50 | let bios_func_name = BIOS_FUNC_LUT.get(bios_func); 51 | 52 | if bios_func_name == () { 53 | println(`Unknown BIOS function: ${bios_func}`); 54 | return; 55 | } 56 | 57 | println(`BIOS: ${bios_func_name} (${bios_func})`); 58 | } 59 | 60 | fn setup() { 61 | let breakpoints = #{ 62 | "0x144": "dump_bios_function" 63 | }; 64 | breakpoints 65 | } 66 | -------------------------------------------------------------------------------- /external/tonc/code/basic/obj_demo/obj_demo.c: -------------------------------------------------------------------------------- 1 | // 2 | // obj_demo.c 3 | // testing various sprite related things 4 | // 5 | // (20031003 - 20060924, Cearn) 6 | 7 | #include 8 | #include "toolbox.h" 9 | #include "metr.h" 10 | 11 | OBJ_ATTR obj_buffer[128]; 12 | OBJ_AFFINE *obj_aff_buffer= (OBJ_AFFINE*)obj_buffer; 13 | 14 | // testing a few sprite things 15 | // D-pad: move 16 | // SELECT: switch palette 17 | // START: toggle mapping mode 18 | // A: horizontal flip 19 | // B: vertical flip 20 | // L & R shift starting tile 21 | void obj_test() 22 | { 23 | int x= 96, y= 32; 24 | u32 tid= 0, pb= 0; // tile id, pal-bank 25 | 26 | OBJ_ATTR *metr= &obj_buffer[0]; 27 | obj_set_attr(metr, 28 | ATTR0_SQUARE, // Square, regular sprite 29 | ATTR1_SIZE_64, // 64x64p, 30 | ATTR2_PALBANK(pb) | tid); // palbank 0, tile 0 31 | 32 | // position sprite (redundant here; the _real_ position 33 | // is set further down 34 | obj_set_pos(metr, x, y); 35 | 36 | while(1) 37 | { 38 | vid_vsync(); 39 | key_poll(); 40 | 41 | // move left/right 42 | x += 2*key_tri_horz(); 43 | 44 | // move up/down 45 | y += 2*key_tri_vert(); 46 | 47 | // increment/decrement starting tile with R/L 48 | tid += bit_tribool(key_hit(-1), KI_R, KI_L); 49 | 50 | // flip 51 | if(key_hit(KEY_A)) // horizontally 52 | metr->attr1 ^= ATTR1_HFLIP; 53 | if(key_hit(KEY_B)) // vertically 54 | metr->attr1 ^= ATTR1_VFLIP; 55 | 56 | // make it glow (via palette swapping) 57 | pb= key_is_down(KEY_SELECT) ? 1 : 0; 58 | 59 | // toggle mapping mode 60 | if(key_hit(KEY_START)) 61 | REG_DISPCNT ^= DCNT_OBJ_1D; 62 | 63 | // Hey look, it's one of them build macros! 64 | metr->attr2= ATTR2_BUILD(tid, pb, 0); 65 | obj_set_pos(metr, x, y); 66 | 67 | oam_copy(oam_mem, obj_buffer, 1); // only need to update one 68 | } 69 | } 70 | 71 | int main() 72 | { 73 | // Places the glyphs of a 4bpp boxed metroid sprite 74 | // into LOW obj memory (cbb == 4) 75 | memcpy(&tile_mem[4][0], metrTiles, metrTilesLen); 76 | memcpy(pal_obj_mem, metrPal, metrPalLen); 77 | 78 | oam_init(obj_buffer, 128); 79 | REG_DISPCNT= DCNT_OBJ | DCNT_OBJ_1D; 80 | 81 | obj_test(); 82 | 83 | while(1); 84 | 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /debugger/src/dbg/debugger.rs: -------------------------------------------------------------------------------- 1 | use super::widgets::cpu::CpuWidget; 2 | use super::widgets::disasm::DisassemblyWidget; 3 | use super::widgets::memory::MemoryWidget; 4 | use super::widgets::ppu::PpuWidget; 5 | use crate::event::{RequestEvent, ResponseEvent}; 6 | use crossbeam_channel::{Receiver, Sender}; 7 | use egui::Context; 8 | 9 | pub struct Debugger { 10 | pub open: bool, 11 | rx: Receiver, 12 | memory_widget: MemoryWidget, 13 | cpu_widget: CpuWidget, 14 | disasm_widget: DisassemblyWidget, 15 | ppu_widget: PpuWidget, 16 | } 17 | 18 | impl Debugger { 19 | pub fn new( 20 | cpu_tx: Sender, memory_tx: Sender, disasm_tx: Sender, 21 | ppu_tx: Sender, rx: Receiver, 22 | ) -> Debugger { 23 | Debugger { 24 | open: false, 25 | rx, 26 | memory_widget: MemoryWidget::new(memory_tx), 27 | cpu_widget: CpuWidget::new(cpu_tx), 28 | disasm_widget: DisassemblyWidget::new(disasm_tx), 29 | ppu_widget: PpuWidget::new(ppu_tx), 30 | } 31 | } 32 | 33 | pub fn update(&mut self, ctx: &Context) { 34 | if !self.open { 35 | return; 36 | } 37 | 38 | match self.rx.try_recv() { 39 | Ok(ResponseEvent::Cpu(cpu)) => self.cpu_widget.update(cpu), 40 | Ok(ResponseEvent::Memory(memory)) => self.memory_widget.update(memory), 41 | Ok(ResponseEvent::Disassembly(pc, r15, disassembly)) => self.disasm_widget.update(disassembly, pc, r15), 42 | Ok(ResponseEvent::Ppu(frames, _tileset, tilemaps, palette, registers, sprites)) => { 43 | // TODO: we ignore tileset cause its been causing issues 44 | self.ppu_widget 45 | .update(ctx, frames, tilemaps, palette, registers, sprites) 46 | } 47 | _ => (), 48 | } 49 | 50 | self.cpu_widget.render(ctx); 51 | self.memory_widget.render(ctx); 52 | self.disasm_widget.render(ctx); 53 | self.ppu_widget.render(ctx); 54 | } 55 | 56 | pub fn toggle_window(&mut self) { 57 | self.open = !self.open; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /gba-core/src/cartridge/storage.rs: -------------------------------------------------------------------------------- 1 | const SANYO_MANUFACTURER_ID: u8 = 0x62; 2 | const SANYO_DEVICE_ID: u8 = 0x13; 3 | const PANASONIC_MANUFACTURER_ID: u8 = 0x32; 4 | const PANASONIC_DEVICE_ID: u8 = 0x1B; 5 | 6 | // TODO: Switch to https://docs.google.com/spreadsheets/d/16-a3qDDkJJNpaYOEXi-xgTv-j1QznXHt9rTUJNFshjo/edit?pli=1&gid=0#gid=0 maybe? 7 | 8 | #[derive(Clone, Copy, PartialEq, Eq)] 9 | pub enum BackupType { 10 | Eeprom4k, 11 | Eeprom64k, 12 | Flash512k, 13 | Flash1m, 14 | Sram, 15 | None, 16 | } 17 | 18 | impl BackupType { 19 | pub fn has_rtc(&self) -> bool { 20 | matches!(self, BackupType::Flash512k | BackupType::Flash1m) 21 | } 22 | 23 | pub fn manufacturer_id(&self) -> u8 { 24 | match self { 25 | BackupType::Flash512k => PANASONIC_MANUFACTURER_ID, 26 | BackupType::Flash1m => SANYO_MANUFACTURER_ID, 27 | _ => unreachable!(), 28 | } 29 | } 30 | 31 | pub fn device_id(&self) -> u8 { 32 | match self { 33 | BackupType::Flash512k => PANASONIC_DEVICE_ID, 34 | BackupType::Flash1m => SANYO_DEVICE_ID, 35 | _ => unreachable!(), 36 | } 37 | } 38 | } 39 | 40 | impl From for BackupType { 41 | fn from(value: u8) -> Self { 42 | match value { 43 | 0 => BackupType::None, 44 | 1 => BackupType::Eeprom4k, 45 | 2 => BackupType::Eeprom64k, 46 | 3 => BackupType::Sram, 47 | 4 => BackupType::Flash512k, 48 | 5 => BackupType::Flash1m, 49 | _ => unreachable!(), 50 | } 51 | } 52 | } 53 | 54 | impl std::fmt::Display for BackupType { 55 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 56 | match self { 57 | BackupType::Eeprom4k => write!(f, "EEPROM 4K"), 58 | BackupType::Eeprom64k => write!(f, "EEPROM 64K"), 59 | BackupType::Flash512k => write!(f, "Flash 512K"), 60 | BackupType::Flash1m => write!(f, "Flash 1M"), 61 | BackupType::Sram => write!(f, "SRAM"), 62 | BackupType::None => write!(f, "None"), 63 | }?; 64 | write!(f, " (has RTC: {})", self.has_rtc()) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tte/chr4r_drawg_b1cts.c: -------------------------------------------------------------------------------- 1 | // 2 | // Tile renderer, var width/height, 1->4bpp tiles, 3 | // recolored with transparency 4 | // 5 | //! \file chr4r_drawg_b1cts.c 6 | //! \author J Vijn 7 | //! \date 20070621 - 20070725 8 | // 9 | /* === NOTES === 10 | * 20070725: Skipping rendering if raw == 0 helps. A lot. Also, there 11 | is more than one way to bitunpack and split between tiles. Which 12 | method is faster is very platform dependent. 13 | * 20070723: Prepping dst stuff inside the drawg and passing along to 14 | renc does NOT help (prolly due to Thumb). Try combining in 15 | asm manually. 16 | */ 17 | 18 | #include "tonc_memdef.h" 19 | #include "tonc_tte.h" 20 | 21 | 22 | // -------------------------------------------------------------------- 23 | // FUNCTIONS 24 | // -------------------------------------------------------------------- 25 | 26 | //! Render 1bpp fonts to 4bpp tiles 27 | void chr4r_drawg_b1cts(uint gid) 28 | { 29 | TTE_BASE_VARS(tc, font); 30 | TTE_CHAR_VARS(font, gid, u8, srcD, srcL, charW, charH); 31 | uint x= tc->cursorX, y= tc->cursorY; 32 | uint srcP= font->cellH, dstP= tc->dst.pitch/4; 33 | 34 | u32 *dstD= (u32*)(tc->dst.data + y/8*dstP + (y%8)*4 + x/8*32), *dstL; 35 | dstP= dstP/4 - 8; 36 | x %= 8; 37 | u32 lsl= 4*x, lsr= 32-4*x, right= x+charW; 38 | 39 | // Inner loop vars 40 | u32 px, pxmask, raw; 41 | u32 ink= tc->cattr[TTE_INK]; 42 | const u32 mask= 0x01010101; 43 | 44 | uint iy, iw; 45 | for(iw=0; iw 8) 70 | dstL[8]= (dstL[8] &~ (pxmask>>lsr) ) | (px>>lsr); 71 | } 72 | dstL++; 73 | 74 | if( ((u32)dstL)%32 == 0 ) 75 | dstL += dstP; 76 | } 77 | } 78 | } 79 | 80 | // EOF 81 | -------------------------------------------------------------------------------- /gba-core/src/input/joypad.rs: -------------------------------------------------------------------------------- 1 | use super::registers::{KeyControl, KeyInput}; 2 | use crate::memory::device::Addressable; 3 | 4 | pub struct Joypad { 5 | status: KeyInput, 6 | irq_control: KeyControl, 7 | } 8 | 9 | impl Joypad { 10 | pub fn new() -> Joypad { 11 | Joypad { 12 | status: KeyInput::all(), 13 | irq_control: KeyControl::empty(), 14 | } 15 | } 16 | 17 | pub fn set_key_state(&mut self, key: KeyInput, pressed: bool) { 18 | if pressed { 19 | self.status.remove(key); 20 | } else { 21 | self.status.insert(key); 22 | } 23 | } 24 | 25 | pub fn is_key_pressed(&self, key: KeyInput) -> bool { 26 | !self.status.contains(key) 27 | } 28 | } 29 | 30 | impl Addressable for Joypad { 31 | fn read(&self, addr: u32) -> u8 { 32 | match addr { 33 | 0x04000130 => self.status.bits() as u8, 34 | 0x04000131 => ((self.status.bits() & 0xff00) >> 8) as u8, 35 | 0x04000132 => self.irq_control.bits() as u8, 36 | 0x04000133 => ((self.irq_control.bits() & 0xff00) >> 8) as u8, 37 | _ => unreachable!(), 38 | } 39 | } 40 | 41 | fn write(&mut self, addr: u32, value: u8) { 42 | match addr { 43 | 0x04000130 => { 44 | self.status = KeyInput::from_bits_truncate(u16::from_le_bytes([value, self.status.bits() as u8])); 45 | } 46 | 0x04000131 => { 47 | self.status = KeyInput::from_bits_truncate(u16::from_le_bytes([ 48 | ((self.status.bits() & 0xff00) >> 8) as u8, 49 | value, 50 | ])); 51 | } 52 | 0x04000132 => { 53 | self.irq_control = 54 | KeyControl::from_bits_truncate(u16::from_le_bytes([value, self.irq_control.bits() as u8])); 55 | } 56 | 0x04000133 => { 57 | self.irq_control = KeyControl::from_bits_truncate(u16::from_le_bytes([ 58 | ((self.irq_control.bits() & 0xff00) >> 8) as u8, 59 | value, 60 | ])); 61 | } 62 | _ => unreachable!(), 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /external/tonc/code/tonc.mak: -------------------------------------------------------------------------------- 1 | # 2 | # Hub makefile for Tonc's demos 3 | # 4 | 5 | # === Variables ======================================================= 6 | 7 | export CROSS := arm-none-eabi- 8 | 9 | LIBTONC := tonclib 10 | GRPDIRS := basic ext adv lab 11 | BINDIR := ../bin 12 | 13 | # List all directories in the group dirs 14 | # Yeah, there's probably a better way :/ 15 | PROJALL := $(foreach dir, $(GRPDIRS), $(shell ls -d $(dir)/*/)) 16 | EXCLUDE := 17 | PROJDIRS := $(filter-out $(foreach proj, $(EXCLUDE), %/$(proj)/), $(PROJALL)) 18 | 19 | DEMO := bigmap 20 | DEMODIR := $(filter %/$(DEMO)/, $(PROJDIRS)) 21 | 22 | # Convert GCC lines to conform to the right IDE, feel free to add more 23 | # GCC : {filename}:{line}: ... 24 | # MSVS: {dir}\{filename}({line}): ... 25 | ifeq ($(IDE),msvc) 26 | 27 | # And switch is DEMO is not in 'basic' or 'ext', 28 | # as the rest behaves differently :/ 29 | ifeq ($(filter basic/% ext/%, lab/%, $(DEMODIR)),) 30 | ERRFIX := 2>&1 | sed -e 's|\(.\+\):\([0-9]\+\):|\1(\2):|' 31 | else 32 | ERRFIX := 2>&1 | sed -e 's|\(.\+\):\([0-9]\+\):|../$(DEMODIR)\1(\2):|' 33 | endif 34 | 35 | endif # /$(IDE) 36 | 37 | .PHONY : build clean build_all clean_all 38 | 39 | # === Build Single ==================================================== 40 | 41 | build: 42 | $(MAKE) -C $(DEMODIR) $(ERRFIX) 43 | 44 | 45 | # === Clean Single ==================================================== 46 | 47 | clean: 48 | @$(MAKE) -C $(DEMODIR) clean 49 | 50 | 51 | # === Build Single ==================================================== 52 | 53 | build_all: libtonc 54 | @echo === Building all projects \(this could take a while\) === 55 | @for proj in $(PROJDIRS) ; \ 56 | do $(MAKE) -s -C $$proj ; done; 57 | @[ -d $(BINDIR) ] || mkdir -p $(BINDIR) 58 | @for proj in $(PROJDIRS); do cp $$proj*.gba $(BINDIR) ; done; 59 | 60 | # === Clean Single ==================================================== 61 | 62 | clean_all: 63 | @echo === Cleaning all projects \(this could take a while\) === 64 | # @$(MAKE) clean -C $(LIBTONC) 65 | @for proj in $(PROJDIRS); \ 66 | do $(MAKE) clean -s -C $$proj ; done; 67 | 68 | 69 | # === Build libtonc =================================================== 70 | 71 | libtonc: 72 | @$(MAKE) -C $(LIBTONC) 73 | 74 | -------------------------------------------------------------------------------- /external/tonc/code/basic/cbb_demo/cbb_demo.c: -------------------------------------------------------------------------------- 1 | // 2 | // cbb_demo.c 3 | // showing char-block boundaries for 4 and 8-bit tile-maps 4 | // 5 | // (20031114 - 20060924, cearn) 6 | 7 | #include "toolbox.h" 8 | 9 | #include "cbb_ids.h" 10 | 11 | #define CBB_4 0 12 | #define SBB_4 2 13 | 14 | #define CBB_8 2 15 | #define SBB_8 4 16 | 17 | void load_tiles() 18 | { 19 | int ii; 20 | TILE *tl= (TILE*)ids4Tiles; 21 | TILE8 *tl8= (TILE8*)ids8Tiles; 22 | 23 | // Loading tiles. don't get freaked out on how it looks 24 | // 4-bit tiles to blocks 0 and 1 25 | tile_mem[0][1]= tl[1]; tile_mem[0][2]= tl[2]; 26 | tile_mem[1][0]= tl[3]; tile_mem[1][1]= tl[4]; 27 | // and the 8-bit tiles to blocks 2 though 5 28 | tile8_mem[2][1]= tl8[1]; tile8_mem[2][2]= tl8[2]; 29 | tile8_mem[3][0]= tl8[3]; tile8_mem[3][1]= tl8[4]; 30 | tile8_mem[4][0]= tl8[5]; tile8_mem[4][1]= tl8[6]; 31 | tile8_mem[5][0]= tl8[7]; tile8_mem[5][1]= tl8[8]; 32 | 33 | // And let's not forget the palette (yes, obj pal too) 34 | u16 *src= (u16*)ids4Pal; 35 | for(ii=0; ii<16; ii++) 36 | pal_bg_mem[ii]= pal_obj_mem[ii]= *src++; 37 | } 38 | 39 | void init_maps() 40 | { 41 | // se4 and se8 map coords: (0,2) and (0,8) 42 | SCR_ENTRY *se4= &se_mem[SBB_4][2*32], *se8= &se_mem[SBB_8][8*32]; 43 | // show first tiles of char-blocks available to bg0 44 | // tiles 1, 2 of char-block CBB_4 45 | se4[0x01]= 0x0001; se4[0x02]= 0x0002; 46 | 47 | // tiles 0, 1 of char-block CBB_4+1 48 | se4[0x20]= 0x0200; se4[0x21]= 0x0201; 49 | 50 | // show first tiles of char-blocks available to bg1 51 | // tiles 1, 2 of char-block CBB_8 (== 2) 52 | se8[0x01]= 0x0001; se8[0x02]= 0x0002; 53 | 54 | // tiles 1, 2 of char-block CBB_8+1 55 | se8[0x20]= 0x0100; se8[0x21]= 0x0101; 56 | 57 | // tiles 1, 2 of char-block CBB_8+2 (== CBB_OBJ_LO) 58 | se8[0x40]= 0x0200; se8[0x41]= 0x0201; 59 | 60 | // tiles 1, 2 of char-block CBB_8+3 (== CBB_OBJ_HI) 61 | se8[0x60]= 0x0300; se8[0x61]= 0x0301; 62 | } 63 | 64 | int main() 65 | { 66 | load_tiles(); 67 | init_maps(); 68 | 69 | // init backgrounds 70 | REG_BG0CNT= BG_CBB(CBB_4) | BG_SBB(SBB_4) | BG_4BPP; 71 | REG_BG1CNT= BG_CBB(CBB_8) | BG_SBB(SBB_8) | BG_8BPP; 72 | // enable backgrounds 73 | REG_DISPCNT= DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_OBJ; 74 | 75 | while(1); 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/asm/tonc_isr_master.s: -------------------------------------------------------------------------------- 1 | // 2 | // Default ISR for interrupts. No automatic nestings. 3 | // 4 | //! \file tonc_isr_master.s 5 | //! \author J Vijn 6 | //! \date 20080320 - 20090801 7 | // 8 | // === NOTES === 9 | 10 | #include "tonc_asminc.h" 11 | 12 | .file "tonc_isr_master.s" 13 | .extern __isr_table; 14 | 15 | /*! \fn IWRAM_CODE void isr_master() 16 | \brief Default irq dispatcher (no automatic nesting) 17 | */ 18 | @ Register list 19 | @ r0 : ®_IE 20 | @ r1 : __isr_table / isr 21 | @ r2 : IF & IE 22 | @ r3 : tmp 23 | @ ip : (IF,IE) 24 | BEGIN_FUNC_ARM(isr_master, CSEC_IWRAM) 25 | @ Read IF/IE 26 | mov r0, #0x04000000 27 | ldr ip, [r0, #0x200]! 28 | and r2, ip, ip, lsr #16 @ irq= IE & IF 29 | 30 | @ Acknowledge irq in IF and for BIOS 31 | strh r2, [r0, #2] 32 | ldr r3, [r0, #-0x208] 33 | orr r3, r3, r2 34 | str r3, [r0, #-0x208] 35 | 36 | @ Search for irq. 37 | ldr r1, =__isr_table 38 | 39 | .Lirq_search: 40 | ldr r3, [r1], #8 41 | tst r3, r2 42 | bne .Lpost_search @ Found one, break off search 43 | cmp r3, #0 44 | bne .Lirq_search @ Not here; try next irq 45 | 46 | @ Search over : return if no isr, otherwise continue. 47 | .Lpost_search: 48 | ldrne r1, [r1, #-4] @ isr= __isr_table[ii-1].isr 49 | cmpne r1, #0 50 | bxeq lr @ If no isr: quit 51 | 52 | @ --- If we're here, we have an isr --- 53 | 54 | ldr r3, [r0, #8] @ Read IME 55 | strb r0, [r0, #8] @ Clear IME 56 | bic r2, ip, r2 57 | strh r2, [r0] @ Clear current irq in IE 58 | 59 | mrs r2, spsr 60 | stmfd sp!, {r2-r3, ip, lr} @ sprs, IME, (IE,IF), lr_irq 61 | 62 | @ Set mode to usr 63 | mrs r3, cpsr 64 | bic r3, r3, #0xDF 65 | orr r3, r3, #0x1F 66 | msr cpsr, r3 67 | 68 | @ Call isr 69 | stmfd sp!, {r0,lr} @ ®_IE, lr_sys 70 | mov lr, pc 71 | bx r1 72 | ldmfd sp!, {r0,lr} @ ®_IE, lr_sys 73 | 74 | @ --- Unwind --- 75 | strb r0, [r0, #8] @ Clear IME again (safety) 76 | 77 | @ Reset mode to irq 78 | mrs r3, cpsr 79 | bic r3, r3, #0xDF 80 | orr r3, r3, #0x92 81 | msr cpsr, r3 82 | 83 | ldmfd sp!, {r2-r3, ip, lr} @ sprs, IME, (IE,IF), lr_irq 84 | msr spsr, r2 @ Restore spsr 85 | strh ip, [r0] @ Restore IE 86 | str r3, [r0, #8] @ Restore IME 87 | 88 | bx lr 89 | END_FUNC(isr_master) 90 | 91 | @ EOF 92 | 93 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/asm/clr_fade_fast.s: -------------------------------------------------------------------------------- 1 | // 2 | // Color fade with 33 alpha levels 3 | // 4 | //! \file tonc_memcpy.s 5 | //! \author J Vijn 6 | //! \date 20071130 - 20071130 7 | 8 | #include "tonc_asminc.h" 9 | 10 | #ifndef CLR_ROUND 11 | #define CLR_ROUND 1 12 | #endif 13 | 14 | /* 15 | void clr_fade_fast(COLOR *src, COLOR clr, COLOR *dst, 16 | int nclrs, u32 alpha) IWRAM_CODE; 17 | */ 18 | //! Fades color arrays \a srca to \a clr into \a dst. 19 | /*! \param src Source array. 20 | * \param clr Final color (at alpha=32). 21 | * \param dst Destination array. 22 | * \param nclrs Number of colors. 23 | * \param alpha Blend weight (range: 0-32). 24 | * \note u32 version, 2 clrs/loop. Loop: 18i/32c, Barrel shifter FTW. 25 | */ 26 | .section .iwram,"ax", %progbits 27 | .align 2 28 | .arm 29 | .global clr_fade_fast 30 | clr_fade_fast: 31 | movs r3, r3, lsr #1 @ adjust nclrs for u32 run 32 | bxeq lr @ quit on nclrs=0 33 | ldr r12, [sp] @ get alpha from stack 34 | stmfd sp!, {r4-r10, lr} 35 | #if(CLR_ROUND==1) 36 | ldr lr, =0x00200401 @ -1-|1-1 37 | rsb r7, lr, lr, lsl #5 @ MASKLO: -g-|b-r 38 | #else 39 | ldr r7, =0x03E07C1F @ MASKLO: -g-|b-r 40 | #endif 41 | mov r6, r7, lsl #5 @ MASKHI: g-|b-r- 42 | 43 | @ Precalc y1 and y2 44 | orr r1, r1, r1, lsl #16 45 | and r9, r7, r1, ror #16 @ precalc: y2= -g-|b-r (ror16) 46 | and r1, r7, r1 @ precalc: y1= -g-|b-r 47 | .Lfade_fast_loop: 48 | ldr r8, [r0], #4 @ a= *pa++ 49 | @ --- -g-|b-r 50 | and r4, r6, r8, lsl #5 @ x/32: (-g-|b-r) 51 | sub r5, r1, r4, lsr #5 @ z: y1-x 52 | mla r4, r5, r12, r4 @ z: (y1-x)*w + x*32 53 | #if(CLR_ROUND==1) 54 | add r4, r4, lr, lsl #4 @ round 55 | #endif 56 | and r10, r7, r4, lsr #5 @ blend(-g-|b-r) 57 | @ --- b-r|-g- (rotated by 16 for great awesome) 58 | and r4, r6, r8, ror #11 @ x/32: -g-|b-r (ror16) 59 | sub r5, r9, r4, lsr #5 @ z: y2-x 60 | mla r4, r5, r12, r4 @ z: (y2-x)*w + x*32 61 | #if(CLR_ROUND==1) 62 | add r4, r4, lr, lsl #4 @ round 63 | #endif 64 | and r4, r7, r4, lsr #5 @ blend(-g-|b-r (ror16)) 65 | @ --- mix -g-|b-r and b-r|-g- 66 | orr r10, r10, r4, ror #16 67 | @ --- write faded, loop 68 | str r10, [r2], #4 @ *dst++= c 69 | subs r3, r3, #1 70 | bgt .Lfade_fast_loop 71 | ldmfd sp!, {r4-r10, lr} 72 | bx lr 73 | 74 | @ EOF 75 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/src/tte/bmp16_drawg_b1cs.c: -------------------------------------------------------------------------------- 1 | // 2 | // Bitmap 16bpp render 3 | // * vwf and fwf 4 | // * any width, height 5 | // * 1->16bpp 6 | // * recolored 7 | // * transparency 8 | // 9 | //! \file bmp16_drawg_b1cs.c 10 | //! \author J Vijn 11 | //! \date 20070605 - 20070704 12 | // 13 | // === NOTES === 14 | 15 | #include "tonc_memdef.h" 16 | 17 | #include "tonc_tte.h" 18 | 19 | // -------------------------------------------------------------------- 20 | // FUNCTIONS 21 | // -------------------------------------------------------------------- 22 | 23 | 24 | //! Linear bitmap, 16bpp transparent character plotter. 25 | /* Works on a 16 bpp bitmap (mode 3 or 5). 26 | \param gid Character to plot. 27 | \note Font req: Any width/height. 1bpp font, 8px stips. 28 | */ 29 | void bmp16_drawg_b1cts(uint gid) 30 | { 31 | TTE_BASE_VARS(tc, font); 32 | TTE_CHAR_VARS(font, gid, u8, srcD, srcL, charW, charH); 33 | TTE_DST_VARS(tc, u16, dstD, dstL, dstP, x0, y0); 34 | uint srcP= font->cellH; 35 | dstD += x0; 36 | 37 | u32 ink= tc->cattr[TTE_INK], raw; 38 | 39 | //# Fixme (src, dst, nx) 40 | uint ix, iy, iw; 41 | for(iw=0; iw0; raw>>=1, ix++) 48 | if(raw&1) 49 | dstL[ix]= ink; 50 | 51 | dstL += dstP/2; 52 | } 53 | srcL += srcP; 54 | } 55 | } 56 | 57 | //! Linear bitmap, 16bpp opaque character plotter. 58 | /* Works on a 16 bpp bitmap (mode 3 or 5). 59 | \param gid Character to plot. 60 | \note Font req: Any width/height. 1bpp font, 8px stips. 61 | */ 62 | void bmp16_drawg_b1cos(uint gid) 63 | { 64 | TTE_BASE_VARS(tc, font); 65 | TTE_CHAR_VARS(font, gid, u8, srcD, srcL, charW, charH); 66 | TTE_DST_VARS(tc, u16, dstD, dstL, dstP, x0, y0); 67 | uint srcP= font->cellH; 68 | 69 | dstD += x0; 70 | 71 | u32 ink= tc->cattr[TTE_INK]; 72 | u32 paper= tc->cattr[TTE_PAPER]; 73 | u32 raw; 74 | 75 | uint ix, iy, iw; 76 | for(iw=0; iw>=1)&1) ? ink : paper; 85 | 86 | dstL += dstP; 87 | } 88 | srcL += srcP; 89 | } 90 | } 91 | 92 | // EOF 93 | -------------------------------------------------------------------------------- /external/tonc/code/tonclib/asm/clr_blend_fast.s: -------------------------------------------------------------------------------- 1 | // 2 | // Color blend with 33 alpha levels 3 | // 4 | //! \file tonc_memcpy.s 5 | //! \author J Vijn 6 | //! \date 20071130 - 20090801 7 | 8 | #include "tonc_asminc.h" 9 | 10 | #ifndef CLR_ROUND 11 | #define CLR_ROUND 1 12 | #endif 13 | 14 | /* 15 | void clr_blend_fast(COLOR *srca, COLOR *srcb, COLOR *dst, 16 | int nclrs, u32 alpha) IWRAM_CODE; 17 | */ 18 | //! Blends color arrays \a srca and \a srcb into \a dst. 19 | /*! \param srca Source array A. 20 | \param srcb Source array B 21 | \param dst Destination array. 22 | \param nclrs Number of colors. 23 | \param alpha Blend weight (range: 0-32). 24 | \note u32 version, 2 clrs/loop. Loop: 18i/32c, Barrel shifter FTW. 25 | \note Properly rounds the blending. If you don't want that, remove 26 | the references to lr. 27 | */ 28 | BEGIN_FUNC_ARM(clr_blend_fast, CSEC_IWRAM) 29 | movs r3, r3, lsr #1 @ adjust nclrs for u32 run 30 | bxeq lr @ quit on nclrs=0 31 | ldr r12, [sp] @ get alpha from stack 32 | stmfd sp!, {r4-r10, lr} 33 | #if(CLR_ROUND==1) 34 | ldr lr, =0x00200401 @ -1-|1-1 35 | rsb r7, lr, lr, lsl #5 @ MASKLO: -g-|b-r 36 | #else 37 | ldr r7, =0x03E07C1F @ MASKLO: -g-|b-r 38 | #endif 39 | mov r6, r7, lsl #5 @ MASKHI: g-|b-r- 40 | .Lbld_fast_loop: 41 | ldr r8, [r0], #4 @ a= *pa++ 42 | ldr r9, [r1], #4 @ b= *pb++ 43 | @ --- -g-|b-r 44 | and r4, r6, r8, lsl #5 @ x/32: (-g-|b-r) 45 | and r5, r7, r9 @ y: -g-|b-r 46 | sub r5, r5, r4, lsr #5 @ z: y-x 47 | mla r4, r5, r12, r4 @ z: (y-x)*w + x*32 48 | #if(CLR_ROUND==1) 49 | add r4, r4, lr, lsl #4 @ round 50 | #endif 51 | and r10, r7, r4, lsr #5 @ blend(-g-|b-r) 52 | @ --- b-r|-g- (rotated by 16 for great awesome) 53 | and r4, r6, r8, ror #11 @ x/32: -g-|b-r (ror16) 54 | and r5, r7, r9, ror #16 @ y: -g-|b-r (ror16) 55 | sub r5, r5, r4, lsr #5 @ z: y-x 56 | mla r4, r5, r12, r4 @ z: (y-x)*w + x*32 57 | #if(CLR_ROUND==1) 58 | add r4, r4, lr, lsl #4 @ round 59 | #endif 60 | and r4, r7, r4, lsr #5 @ blend(-g-|b-r (ror16)) 61 | @ --- mix -g-|b-r and b-r|-g- 62 | orr r10, r10, r4, ror #16 63 | @ --- write blended, loop 64 | str r10, [r2], #4 @ *dst++= c 65 | subs r3, r3, #1 66 | bgt .Lbld_fast_loop 67 | ldmfd sp!, {r4-r10, lr} 68 | bx lr 69 | END_FUNC(clr_blend_fast) 70 | 71 | 72 | @ EOF 73 | -------------------------------------------------------------------------------- /external/tonc/code/ext/mos_demo/mos_demo.c: -------------------------------------------------------------------------------- 1 | // 2 | // mos_demo.c 3 | // testing a mosaic sprite and background 4 | // 5 | // (20031013 - 20071203, cearn) 6 | // === NOTES === 7 | // * bg/oam use: 8 | // bg 0, cbb 0, sbb 31, pb 0: text 9 | // bg 1, cbb 1, sbb 30, pb 1: bg metroid 10 | // oam 0: tile 0-63: obj metroid 11 | 12 | #include 13 | #include 14 | #include "metr.h" 15 | 16 | void test_mosaic() 17 | { 18 | tte_printf("#{P:48,8}obj#{P:168,8}bg"); 19 | tte_set_margins(4, SCR_H-30, SCR_W-4, SCR_H-4); 20 | 21 | POINT pt_obj={0,0}, pt_bg={0,0}; 22 | POINT *ppt= &pt_obj; 23 | 24 | while(1) 25 | { 26 | vid_vsync(); 27 | 28 | // control the mosaic 29 | key_poll(); 30 | 31 | // switch between bg or obj mosaic 32 | ppt= key_is_down(KEY_A) ? &pt_bg : &pt_obj; 33 | 34 | ppt->x += key_tri_horz(); // inc/dec h-mosaic 35 | ppt->y -= key_tri_vert(); // inc/dec v-mosaic 36 | 37 | ppt->x= clamp(ppt->x, 0, 0x80); 38 | ppt->y= clamp(ppt->y, 0, 0x80); 39 | 40 | REG_MOSAIC= MOS_BUILD(pt_bg.x>>3, pt_bg.y>>3, 41 | pt_obj.x>>3, pt_obj.y>>3); 42 | 43 | tte_printf("#{es;P}obj h,v: %2d,%2d\n bg h,v: %2d,%2d", 44 | pt_obj.x>>3, pt_obj.y>>3, pt_bg.x>>3, pt_bg.y>>3); 45 | } 46 | } 47 | 48 | void load_metr() 49 | { 50 | int ix, iy; 51 | 52 | memcpy32(&tile_mem[1][0], metrTiles, metrTilesLen/4); 53 | memcpy32(&tile_mem[4][0], metrTiles, metrTilesLen/4); 54 | memcpy32(pal_obj_mem, metrPal, metrPalLen/4); 55 | 56 | // create object: oe0 57 | OBJ_ATTR *metr= &oam_mem[0]; 58 | obj_set_attr(metr, ATTR0_SQUARE | ATTR0_MOSAIC, ATTR1_SIZE_64, 0); 59 | obj_set_pos(metr, 32, 24); // left-center 60 | 61 | // create bg map: bg1, cbb1, sbb 31 62 | for(ix=1; ix<16; ix++) 63 | pal_bg_mem[ix+16]= pal_obj_mem[ix] ^ CLR_WHITE; 64 | 65 | SCR_ENTRY *pse= &se_mem[30][3*32+18]; // right-center 66 | for(iy=0; iy<8; iy++) 67 | for(ix=0; ix<8; ix++) 68 | pse[iy*32+ix]= (iy*8+ix) | SE_PALBANK(1); 69 | 70 | REG_BG1CNT= BG_CBB(1) | BG_SBB(30) | BG_MOSAIC; 71 | } 72 | 73 | int main() 74 | { 75 | // setup sprite 76 | oam_init(oam_mem, 128); 77 | 78 | load_metr(); 79 | 80 | // set-up text: bg0, cbb0, sbb31 81 | tte_init_chr4c_b4_default(0, BG_CBB(2)|BG_SBB(31)); 82 | tte_init_con(); 83 | 84 | REG_DISPCNT= DCNT_BG0 | DCNT_BG1 | DCNT_OBJ | DCNT_OBJ_1D; 85 | 86 | test_mosaic(); 87 | 88 | return 0; 89 | } 90 | --------------------------------------------------------------------------------