romdev-mcp 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +726 -0
- package/LICENSE +45 -0
- package/NOTICE +86 -0
- package/README.md +46 -0
- package/examples/README.md +36 -0
- package/examples/art-first-workflow/README.md +205 -0
- package/examples/atari2600/main.asm +143 -0
- package/examples/atari2600/templates/default.asm +183 -0
- package/examples/atari2600/templates/mini_invaders.asm +381 -0
- package/examples/atari2600/templates/music_demo.asm +322 -0
- package/examples/atari2600/templates/paddle.asm +345 -0
- package/examples/atari2600/templates/single_screen.asm +242 -0
- package/examples/atari7800/main.c +88 -0
- package/examples/atari7800/templates/default.c +183 -0
- package/examples/atari7800/templates/hello_sprite.c +141 -0
- package/examples/atari7800/templates/music_demo.c +123 -0
- package/examples/atari7800/templates/platformer.c +159 -0
- package/examples/atari7800/templates/puzzle.c +164 -0
- package/examples/atari7800/templates/racing.c +139 -0
- package/examples/atari7800/templates/shmup.c +148 -0
- package/examples/atari7800/templates/sports.c +207 -0
- package/examples/c64/main.c +63 -0
- package/examples/c64/templates/hello_sprite.c +117 -0
- package/examples/c64/templates/music_demo.c +131 -0
- package/examples/c64/templates/platformer.c +194 -0
- package/examples/c64/templates/puzzle.c +178 -0
- package/examples/c64/templates/racing.c +140 -0
- package/examples/c64/templates/shmup.c +201 -0
- package/examples/c64/templates/sports.c +109 -0
- package/examples/c64/templates/tile_engine.c +174 -0
- package/examples/gb/main.asm +106 -0
- package/examples/gb/main.c +49 -0
- package/examples/gb/templates/default.c +58 -0
- package/examples/gb/templates/hello_sprite.c +130 -0
- package/examples/gb/templates/music_demo.c +52 -0
- package/examples/gb/templates/platformer.c +178 -0
- package/examples/gb/templates/puzzle.c +217 -0
- package/examples/gb/templates/racing.c +158 -0
- package/examples/gb/templates/shmup.c +172 -0
- package/examples/gb/templates/sports.c +136 -0
- package/examples/gb/templates/tile_engine.c +280 -0
- package/examples/gba/templates/gba_hello.c +64 -0
- package/examples/gba/templates/maxmod_demo.c +105 -0
- package/examples/gba/templates/platformer.c +215 -0
- package/examples/gba/templates/puzzle.c +237 -0
- package/examples/gba/templates/racing.c +175 -0
- package/examples/gba/templates/shmup.c +197 -0
- package/examples/gba/templates/sports.c +177 -0
- package/examples/gba/templates/tonc_hello.c +72 -0
- package/examples/gba/templates/tonc_hello_sprite.c +109 -0
- package/examples/gbc/main.asm +123 -0
- package/examples/gbc/templates/default.c +61 -0
- package/examples/gbc/templates/hello_sprite.c +140 -0
- package/examples/gbc/templates/music_demo.c +63 -0
- package/examples/gbc/templates/platformer.c +181 -0
- package/examples/gbc/templates/puzzle.c +217 -0
- package/examples/gbc/templates/racing.c +164 -0
- package/examples/gbc/templates/shmup.c +188 -0
- package/examples/gbc/templates/sports.c +142 -0
- package/examples/gbc/templates/tile_engine.c +280 -0
- package/examples/genesis/main.s +161 -0
- package/examples/genesis/templates/hello_sprite.c +75 -0
- package/examples/genesis/templates/platformer.c +166 -0
- package/examples/genesis/templates/puzzle.c +240 -0
- package/examples/genesis/templates/racing.c +170 -0
- package/examples/genesis/templates/sgdk_hello.c +41 -0
- package/examples/genesis/templates/shmup.c +188 -0
- package/examples/genesis/templates/shmup_2p.c +244 -0
- package/examples/genesis/templates/sports.c +172 -0
- package/examples/genesis/templates/tile_engine.c +135 -0
- package/examples/genesis/templates/xgm2_demo.c +53 -0
- package/examples/genesis/templates/xgm2_demo_data.s +27 -0
- package/examples/gg/main.c +10 -0
- package/examples/gg/templates/default.c +156 -0
- package/examples/gg/templates/hello_sprite.c +90 -0
- package/examples/gg/templates/music_demo.c +156 -0
- package/examples/gg/templates/platformer.c +220 -0
- package/examples/gg/templates/puzzle.c +204 -0
- package/examples/gg/templates/racing.c +161 -0
- package/examples/gg/templates/shmup.c +188 -0
- package/examples/gg/templates/sports.c +137 -0
- package/examples/gg/templates/tile_engine.c +137 -0
- package/examples/lynx/main.c +4 -0
- package/examples/lynx/templates/default.c +41 -0
- package/examples/lynx/templates/hello_sprite.c +39 -0
- package/examples/lynx/templates/music_demo.c +37 -0
- package/examples/lynx/templates/platformer.c +72 -0
- package/examples/lynx/templates/puzzle.c +142 -0
- package/examples/lynx/templates/racing.c +94 -0
- package/examples/lynx/templates/shmup.c +132 -0
- package/examples/lynx/templates/sports.c +59 -0
- package/examples/nes/main.c +143 -0
- package/examples/nes/space-shooter/README.md +68 -0
- package/examples/nes/space-shooter/main.c +441 -0
- package/examples/nes/space-shooter/nes_runtime.c +347 -0
- package/examples/nes/space-shooter/nes_runtime.h +141 -0
- package/examples/nes/templates/default.c +41 -0
- package/examples/nes/templates/hello_sprite.c +104 -0
- package/examples/nes/templates/music_demo.c +80 -0
- package/examples/nes/templates/platformer.c +171 -0
- package/examples/nes/templates/puzzle.c +232 -0
- package/examples/nes/templates/racing.c +203 -0
- package/examples/nes/templates/shmup.c +228 -0
- package/examples/nes/templates/sports.c +205 -0
- package/examples/nes/templates/tile_engine.c +224 -0
- package/examples/porting-across-platforms/README.md +59 -0
- package/examples/sms/main.c +129 -0
- package/examples/sms/templates/default.c +110 -0
- package/examples/sms/templates/hello_sprite.c +90 -0
- package/examples/sms/templates/music_demo.c +151 -0
- package/examples/sms/templates/platformer.c +215 -0
- package/examples/sms/templates/puzzle.c +204 -0
- package/examples/sms/templates/racing.c +161 -0
- package/examples/sms/templates/shmup.c +167 -0
- package/examples/sms/templates/shmup_2p.c +219 -0
- package/examples/sms/templates/sports.c +147 -0
- package/examples/sms/templates/tile_engine.c +137 -0
- package/examples/snes/main.asm +70 -0
- package/examples/snes/templates/c-hello-data.asm +28 -0
- package/examples/snes/templates/c-hello.c +71 -0
- package/examples/snes/templates/default-data.asm +36 -0
- package/examples/snes/templates/default.c +74 -0
- package/examples/snes/templates/hello_sprite-data.asm +45 -0
- package/examples/snes/templates/hello_sprite.c +76 -0
- package/examples/snes/templates/music_demo-data.asm +20 -0
- package/examples/snes/templates/music_demo.c +83 -0
- package/examples/snes/templates/platformer-data.asm +27 -0
- package/examples/snes/templates/platformer.c +142 -0
- package/examples/snes/templates/puzzle-data.asm +14 -0
- package/examples/snes/templates/puzzle.c +199 -0
- package/examples/snes/templates/racing-data.asm +33 -0
- package/examples/snes/templates/racing.c +146 -0
- package/examples/snes/templates/shmup-data.asm +61 -0
- package/examples/snes/templates/shmup.c +199 -0
- package/examples/snes/templates/sports-data.asm +28 -0
- package/examples/snes/templates/sports.c +144 -0
- package/package.json +83 -0
- package/src/cli/smoke.js +283 -0
- package/src/cores/registry.js +95 -0
- package/src/host/LibretroHost.js +502 -0
- package/src/host/callbacks.js +444 -0
- package/src/host/chafa-render.js +170 -0
- package/src/host/coreLoader.js +57 -0
- package/src/host/cpu-state.js +422 -0
- package/src/host/dsp-state.js +188 -0
- package/src/host/framebuffer.js +115 -0
- package/src/host/gpgx-state.js +309 -0
- package/src/host/index.js +4 -0
- package/src/host/retroConstants.js +72 -0
- package/src/host/snes9x-state.js +35 -0
- package/src/host/types.js +280 -0
- package/src/mcp/disclosure.js +250 -0
- package/src/mcp/log.js +87 -0
- package/src/mcp/server.js +433 -0
- package/src/mcp/state.js +83 -0
- package/src/mcp/tools/address-to-symbol.js +151 -0
- package/src/mcp/tools/art-loaders.js +740 -0
- package/src/mcp/tools/assets.js +89 -0
- package/src/mcp/tools/audio.js +173 -0
- package/src/mcp/tools/cart-parts.js +649 -0
- package/src/mcp/tools/diff-roms.js +412 -0
- package/src/mcp/tools/disasm.js +980 -0
- package/src/mcp/tools/find-references.js +361 -0
- package/src/mcp/tools/font-map.js +353 -0
- package/src/mcp/tools/frame.js +249 -0
- package/src/mcp/tools/free-space.js +95 -0
- package/src/mcp/tools/index.js +351 -0
- package/src/mcp/tools/input-layout.js +215 -0
- package/src/mcp/tools/input.js +142 -0
- package/src/mcp/tools/lifecycle.js +110 -0
- package/src/mcp/tools/lospec.js +156 -0
- package/src/mcp/tools/memory.js +169 -0
- package/src/mcp/tools/metasprite-tools.js +261 -0
- package/src/mcp/tools/platform-docs.js +102 -0
- package/src/mcp/tools/platform-tools.js +1063 -0
- package/src/mcp/tools/platforms.js +86 -0
- package/src/mcp/tools/playtest.js +280 -0
- package/src/mcp/tools/preview-tile.js +360 -0
- package/src/mcp/tools/project.js +1885 -0
- package/src/mcp/tools/record.js +131 -0
- package/src/mcp/tools/rendering-context.js +700 -0
- package/src/mcp/tools/rom-id.js +256 -0
- package/src/mcp/tools/run-until.js +173 -0
- package/src/mcp/tools/snippets.js +235 -0
- package/src/mcp/tools/splice-chr.js +215 -0
- package/src/mcp/tools/sprite-pipeline.js +614 -0
- package/src/mcp/tools/state.js +99 -0
- package/src/mcp/tools/symbols.js +277 -0
- package/src/mcp/tools/tile-inspect.js +206 -0
- package/src/mcp/tools/toolchain.js +680 -0
- package/src/mcp/tools/watch-memory.js +212 -0
- package/src/mcp/tools/which-tiles.js +193 -0
- package/src/mcp/util.js +85 -0
- package/src/observer/bus.js +127 -0
- package/src/observer/livestream.html +589 -0
- package/src/observer/server.js +66 -0
- package/src/observer/tool-wrap.js +115 -0
- package/src/platforms/atari2600/MENTAL_MODEL.md +185 -0
- package/src/platforms/atari2600/TROUBLESHOOTING.md +155 -0
- package/src/platforms/atari2600/UPSTREAM_SOURCES.md +49 -0
- package/src/platforms/atari2600/lib/README.md +67 -0
- package/src/platforms/atari2600/lib/cc65-src/crt0.s +49 -0
- package/src/platforms/atari2600/lib/cc65-src/ctype.s +5 -0
- package/src/platforms/atari2600/lib/kernel_skeleton.asm +85 -0
- package/src/platforms/atari2600/lib/player_kernel.asm +87 -0
- package/src/platforms/atari2600/lib/playfield_kernel.asm +63 -0
- package/src/platforms/atari2600/lib/read_joystick.asm +76 -0
- package/src/platforms/atari2600/lib/score_kernel.asm +141 -0
- package/src/platforms/atari2600/lib/vcs_constants.h +97 -0
- package/src/platforms/atari2600/lib/vectors.asm +16 -0
- package/src/platforms/atari2600/tia.js +355 -0
- package/src/platforms/atari7800/MENTAL_MODEL.md +306 -0
- package/src/platforms/atari7800/TROUBLESHOOTING.md +195 -0
- package/src/platforms/atari7800/UPSTREAM_SOURCES.md +43 -0
- package/src/platforms/atari7800/lib/README.md +45 -0
- package/src/platforms/atari7800/lib/c/atari7800_music.c +215 -0
- package/src/platforms/atari7800/lib/c/atari7800_music.h +33 -0
- package/src/platforms/atari7800/lib/c/atari7800_sfx.c +74 -0
- package/src/platforms/atari7800/lib/c/atari7800_sfx.h +45 -0
- package/src/platforms/atari7800/lib/cc65-src/clock.s +69 -0
- package/src/platforms/atari7800/lib/cc65-src/clocks_per_sec.s +34 -0
- package/src/platforms/atari7800/lib/cc65-src/clrscr.s +27 -0
- package/src/platforms/atari7800/lib/cc65-src/conio.s +226 -0
- package/src/platforms/atari7800/lib/cc65-src/conio_font.s +278 -0
- package/src/platforms/atari7800/lib/cc65-src/cputc.s +139 -0
- package/src/platforms/atari7800/lib/cc65-src/crt0.s +71 -0
- package/src/platforms/atari7800/lib/cc65-src/ctype.s +5 -0
- package/src/platforms/atari7800/lib/cc65-src/exehdr.s +46 -0
- package/src/platforms/atari7800/lib/cc65-src/extra/mono.s +28 -0
- package/src/platforms/atari7800/lib/cc65-src/extzp.inc +15 -0
- package/src/platforms/atari7800/lib/cc65-src/extzp.s +15 -0
- package/src/platforms/atari7800/lib/cc65-src/get_tv.s +65 -0
- package/src/platforms/atari7800/lib/cc65-src/irq.s +36 -0
- package/src/platforms/atari7800/lib/cc65-src/joy/atari7800-stdjoy.s +197 -0
- package/src/platforms/atari7800/lib/cc65-src/joy_stat_stddrv.s +14 -0
- package/src/platforms/atari7800/lib/cc65-src/libref.s +8 -0
- package/src/platforms/atari7800/lib/cc65-src/mono_clrscr.s +27 -0
- package/src/platforms/atari7800/lib/cc65-src/mono_conio.s +231 -0
- package/src/platforms/atari7800/lib/cc65-src/mono_cputc.s +102 -0
- package/src/platforms/atari7800/lib/cc65-src/mono_font.s +2065 -0
- package/src/platforms/atari7800/lib/cc65-src/mono_setcursor.s +214 -0
- package/src/platforms/atari7800/lib/cc65-src/setcursor.s +214 -0
- package/src/platforms/atari7800/lib/cc65-src/textcolor.s +53 -0
- package/src/platforms/atari7800/lib/cc65-src/wherex.s +19 -0
- package/src/platforms/atari7800/lib/cc65-src/wherey.s +19 -0
- package/src/platforms/atari7800/lib/display_list.asm +53 -0
- package/src/platforms/atari7800/lib/maria_init.asm +48 -0
- package/src/platforms/atari7800/lib/maria_registers.h +61 -0
- package/src/platforms/atari7800/lib/palette_load.asm +53 -0
- package/src/platforms/atari7800/lib/read_pad.asm +57 -0
- package/src/platforms/atari7800/lib/vblank_wait.asm +16 -0
- package/src/platforms/atari7800/maria.js +220 -0
- package/src/platforms/c64/MENTAL_MODEL.md +175 -0
- package/src/platforms/c64/TROUBLESHOOTING.md +130 -0
- package/src/platforms/c64/UPSTREAM_SOURCES.md +35 -0
- package/src/platforms/c64/image-to-tilemap.js +190 -0
- package/src/platforms/c64/lib/README.md +52 -0
- package/src/platforms/c64/lib/basic_stub.s +25 -0
- package/src/platforms/c64/lib/c/c64_music.c +248 -0
- package/src/platforms/c64/lib/c/c64_music.h +36 -0
- package/src/platforms/c64/lib/c/c64_sfx.c +94 -0
- package/src/platforms/c64/lib/c/c64_sfx.h +37 -0
- package/src/platforms/c64/lib/c64_registers.h +108 -0
- package/src/platforms/c64/lib/cc65-src/_scrsize.s +12 -0
- package/src/platforms/c64/lib/cc65-src/acc_c128_speed.s +5 -0
- package/src/platforms/c64/lib/cc65-src/acc_c64dtv_speed.s +64 -0
- package/src/platforms/c64/lib/cc65-src/acc_c65_speed.s +69 -0
- package/src/platforms/c64/lib/cc65-src/acc_chameleon_speed.s +100 -0
- package/src/platforms/c64/lib/cc65-src/acc_detect_c128.s +33 -0
- package/src/platforms/c64/lib/cc65-src/acc_detect_c64dtv.s +44 -0
- package/src/platforms/c64/lib/cc65-src/acc_detect_c65.s +55 -0
- package/src/platforms/c64/lib/cc65-src/acc_detect_chameleon.s +39 -0
- package/src/platforms/c64/lib/cc65-src/acc_detect_scpu.s +34 -0
- package/src/platforms/c64/lib/cc65-src/acc_detect_turbomaster.s +45 -0
- package/src/platforms/c64/lib/cc65-src/acc_scpu_speed.s +59 -0
- package/src/platforms/c64/lib/cc65-src/acc_turbomaster_speed.s +56 -0
- package/src/platforms/c64/lib/cc65-src/bordercolor.s +17 -0
- package/src/platforms/c64/lib/cc65-src/break.s +108 -0
- package/src/platforms/c64/lib/cc65-src/cgetc.s +62 -0
- package/src/platforms/c64/lib/cc65-src/clrscr.s +11 -0
- package/src/platforms/c64/lib/cc65-src/color.s +24 -0
- package/src/platforms/c64/lib/cc65-src/conio.s +10 -0
- package/src/platforms/c64/lib/cc65-src/cputc.s +105 -0
- package/src/platforms/c64/lib/cc65-src/crt0.s +117 -0
- package/src/platforms/c64/lib/cc65-src/devnum.s +7 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-65816.s +377 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-c256k.s +508 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-dqbb.s +447 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-georam.s +355 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-isepic.s +276 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-kerberos.s +281 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-ram.s +270 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-ramcart.s +297 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-reu.s +286 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-rrr.s +363 -0
- package/src/platforms/c64/lib/cc65-src/emd/c64-vdc.s +405 -0
- package/src/platforms/c64/lib/cc65-src/emd/dtv-himem.s +251 -0
- package/src/platforms/c64/lib/cc65-src/extra/soft80.s +71 -0
- package/src/platforms/c64/lib/cc65-src/extra/soft80mono.s +74 -0
- package/src/platforms/c64/lib/cc65-src/extra/tgimousedata.s +21 -0
- package/src/platforms/c64/lib/cc65-src/get_ostype.s +43 -0
- package/src/platforms/c64/lib/cc65-src/get_tv.s +20 -0
- package/src/platforms/c64/lib/cc65-src/gettime.s +83 -0
- package/src/platforms/c64/lib/cc65-src/irq.s +49 -0
- package/src/platforms/c64/lib/cc65-src/joy/c64-hitjoy.s +218 -0
- package/src/platforms/c64/lib/cc65-src/joy/c64-numpad.s +155 -0
- package/src/platforms/c64/lib/cc65-src/joy/c64-ptvjoy.s +146 -0
- package/src/platforms/c64/lib/cc65-src/joy/c64-stdjoy.s +111 -0
- package/src/platforms/c64/lib/cc65-src/joy_stat_stddrv.s +14 -0
- package/src/platforms/c64/lib/cc65-src/joy_stddrv.s +14 -0
- package/src/platforms/c64/lib/cc65-src/kbhit.s +23 -0
- package/src/platforms/c64/lib/cc65-src/kbrepeat.s +14 -0
- package/src/platforms/c64/lib/cc65-src/kernal.s +53 -0
- package/src/platforms/c64/lib/cc65-src/kplot.s +22 -0
- package/src/platforms/c64/lib/cc65-src/libref.s +16 -0
- package/src/platforms/c64/lib/cc65-src/mainargs.s +137 -0
- package/src/platforms/c64/lib/cc65-src/mcbdefault.s +146 -0
- package/src/platforms/c64/lib/cc65-src/mcbspritedata.s +4 -0
- package/src/platforms/c64/lib/cc65-src/mou/c64-1351.s +467 -0
- package/src/platforms/c64/lib/cc65-src/mou/c64-inkwell.s +446 -0
- package/src/platforms/c64/lib/cc65-src/mou/c64-joy.s +451 -0
- package/src/platforms/c64/lib/cc65-src/mou/c64-pot.s +409 -0
- package/src/platforms/c64/lib/cc65-src/mouse_stat_stddrv.s +14 -0
- package/src/platforms/c64/lib/cc65-src/mouse_stddrv.s +14 -0
- package/src/platforms/c64/lib/cc65-src/mouseref.s +23 -0
- package/src/platforms/c64/lib/cc65-src/pencalib.c +94 -0
- package/src/platforms/c64/lib/cc65-src/randomize.s +18 -0
- package/src/platforms/c64/lib/cc65-src/revers.s +27 -0
- package/src/platforms/c64/lib/cc65-src/ser/c64-swlink.s +484 -0
- package/src/platforms/c64/lib/cc65-src/ser_stat_stddrv.s +14 -0
- package/src/platforms/c64/lib/cc65-src/ser_stddrv.s +13 -0
- package/src/platforms/c64/lib/cc65-src/settime.s +84 -0
- package/src/platforms/c64/lib/cc65-src/soft80.inc +46 -0
- package/src/platforms/c64/lib/cc65-src/soft80_cgetc.s +85 -0
- package/src/platforms/c64/lib/cc65-src/soft80_charset.s +182 -0
- package/src/platforms/c64/lib/cc65-src/soft80_color.s +159 -0
- package/src/platforms/c64/lib/cc65-src/soft80_conio.s +157 -0
- package/src/platforms/c64/lib/cc65-src/soft80_cpeekc.s +148 -0
- package/src/platforms/c64/lib/cc65-src/soft80_cpeekcolor.s +19 -0
- package/src/platforms/c64/lib/cc65-src/soft80_cpeekrevers.s +15 -0
- package/src/platforms/c64/lib/cc65-src/soft80_cpeeks.s +71 -0
- package/src/platforms/c64/lib/cc65-src/soft80_cputc.s +521 -0
- package/src/platforms/c64/lib/cc65-src/soft80_kclrscr.s +76 -0
- package/src/platforms/c64/lib/cc65-src/soft80_kplot.s +63 -0
- package/src/platforms/c64/lib/cc65-src/soft80_scrsize.s +14 -0
- package/src/platforms/c64/lib/cc65-src/soft80mono_cgetc.s +67 -0
- package/src/platforms/c64/lib/cc65-src/soft80mono_color.s +65 -0
- package/src/platforms/c64/lib/cc65-src/soft80mono_conio.s +168 -0
- package/src/platforms/c64/lib/cc65-src/soft80mono_cpeekcolor.s +17 -0
- package/src/platforms/c64/lib/cc65-src/soft80mono_cputc.s +204 -0
- package/src/platforms/c64/lib/cc65-src/soft80mono_kclrscr.s +63 -0
- package/src/platforms/c64/lib/cc65-src/soft80mono_kplot.s +52 -0
- package/src/platforms/c64/lib/cc65-src/status.s +15 -0
- package/src/platforms/c64/lib/cc65-src/sysuname.s +37 -0
- package/src/platforms/c64/lib/cc65-src/tgi/c64-hi.s +881 -0
- package/src/platforms/c64/lib/cc65-src/tgi_stat_stddrv.s +14 -0
- package/src/platforms/c64/lib/cc65-src/tgi_stddrv.s +13 -0
- package/src/platforms/c64/lib/cc65-src/tmcommon.s +67 -0
- package/src/platforms/c64/lib/cc65-src/waitvsync.s +18 -0
- package/src/platforms/c64/lib/read_joystick.s +28 -0
- package/src/platforms/c64/lib/sid_play.s +48 -0
- package/src/platforms/c64/lib/sprite_table.s +73 -0
- package/src/platforms/c64/lib/vic_init.s +47 -0
- package/src/platforms/c64/sid.js +128 -0
- package/src/platforms/c64/vic.js +273 -0
- package/src/platforms/common/default-palette.js +139 -0
- package/src/platforms/common/image-to-tiles.js +407 -0
- package/src/platforms/common/intent.js +111 -0
- package/src/platforms/common/metasprite-adapters.js +279 -0
- package/src/platforms/common/metasprite-codegen.js +192 -0
- package/src/platforms/common/metasprite-core.js +201 -0
- package/src/platforms/common/metasprite.js +89 -0
- package/src/platforms/common/platform-palette.js +137 -0
- package/src/platforms/common/registers.js +329 -0
- package/src/platforms/common/render-tiles.js +86 -0
- package/src/platforms/common/screenshot-sprite.js +153 -0
- package/src/platforms/common/tile-decode.js +149 -0
- package/src/platforms/gb/MENTAL_MODEL.md +252 -0
- package/src/platforms/gb/TROUBLESHOOTING.md +221 -0
- package/src/platforms/gb/UPSTREAM_SOURCES.md +43 -0
- package/src/platforms/gb/image-to-tilemap.js +173 -0
- package/src/platforms/gb/lib/README.md +115 -0
- package/src/platforms/gb/lib/c/LICENSE-HUGEDRIVER +25 -0
- package/src/platforms/gb/lib/c/README.md +120 -0
- package/src/platforms/gb/lib/c/SDCC_GOTCHAS.md +189 -0
- package/src/platforms/gb/lib/c/gb_crt0.s +163 -0
- package/src/platforms/gb/lib/c/gb_hardware.h +113 -0
- package/src/platforms/gb/lib/c/gb_runtime.c +284 -0
- package/src/platforms/gb/lib/c/gb_runtime.h +145 -0
- package/src/platforms/gb/lib/c/hUGEDriver.c +191 -0
- package/src/platforms/gb/lib/c/hUGEDriver.h +95 -0
- package/src/platforms/gb/lib/c/hUGEDriver.upstream.asm +1908 -0
- package/src/platforms/gb/lib/c/lcd_init.c +19 -0
- package/src/platforms/gb/lib/c/patch-header.js +154 -0
- package/src/platforms/gb/lib/c/song_data.c +88 -0
- package/src/platforms/gb/lib/c/unroll.h +52 -0
- package/src/platforms/gb/lib/c/wait_vblank.c +14 -0
- package/src/platforms/gb/lib/dma_oam.asm +51 -0
- package/src/platforms/gb/lib/header.asm +56 -0
- package/src/platforms/gb/lib/joypad_read.asm +47 -0
- package/src/platforms/gb/lib/lcd_init.asm +44 -0
- package/src/platforms/gb/lib/load_palette.asm +25 -0
- package/src/platforms/gb/lib/load_tiles.asm +29 -0
- package/src/platforms/gb/lib/vblank_wait.asm +31 -0
- package/src/platforms/gb/ppu.js +574 -0
- package/src/platforms/gba/MENTAL_MODEL.md +203 -0
- package/src/platforms/gba/TROUBLESHOOTING.md +250 -0
- package/src/platforms/gba/UPSTREAM_SOURCES.md +41 -0
- package/src/platforms/gba/lib/arm-archives/libc.a +0 -0
- package/src/platforms/gba/lib/arm-archives/libgcc.a +0 -0
- package/src/platforms/gba/lib/arm-archives/libnosys.a +0 -0
- package/src/platforms/gba/lib/c/gba_sfx.c +81 -0
- package/src/platforms/gba/lib/c/gba_sfx.h +48 -0
- package/src/platforms/gba/lib/libgba/crtbegin.o +0 -0
- package/src/platforms/gba/lib/libgba/crtend.o +0 -0
- package/src/platforms/gba/lib/libgba/crti.o +0 -0
- package/src/platforms/gba/lib/libgba/crtn.o +0 -0
- package/src/platforms/gba/lib/libgba/gba_cart.ld +319 -0
- package/src/platforms/gba/lib/libgba/gba_crt0.s +258 -0
- package/src/platforms/gba/lib/libgba/include/BoyScout.h +128 -0
- package/src/platforms/gba/lib/libgba/include/disc.h +36 -0
- package/src/platforms/gba/lib/libgba/include/disc_io.h +64 -0
- package/src/platforms/gba/lib/libgba/include/dldi.h +112 -0
- package/src/platforms/gba/lib/libgba/include/erapi.h +195 -0
- package/src/platforms/gba/lib/libgba/include/fade.h +76 -0
- package/src/platforms/gba/lib/libgba/include/gba.h +47 -0
- package/src/platforms/gba/lib/libgba/include/gba_affine.h +83 -0
- package/src/platforms/gba/lib/libgba/include/gba_base.h +122 -0
- package/src/platforms/gba/lib/libgba/include/gba_compression.h +66 -0
- package/src/platforms/gba/lib/libgba/include/gba_console.h +55 -0
- package/src/platforms/gba/lib/libgba/include/gba_dma.h +100 -0
- package/src/platforms/gba/lib/libgba/include/gba_input.h +127 -0
- package/src/platforms/gba/lib/libgba/include/gba_interrupt.h +146 -0
- package/src/platforms/gba/lib/libgba/include/gba_multiboot.h +72 -0
- package/src/platforms/gba/lib/libgba/include/gba_sio.h +124 -0
- package/src/platforms/gba/lib/libgba/include/gba_sound.h +356 -0
- package/src/platforms/gba/lib/libgba/include/gba_sprites.h +195 -0
- package/src/platforms/gba/lib/libgba/include/gba_systemcalls.h +194 -0
- package/src/platforms/gba/lib/libgba/include/gba_timers.h +63 -0
- package/src/platforms/gba/lib/libgba/include/gba_types.h +60 -0
- package/src/platforms/gba/lib/libgba/include/gba_video.h +307 -0
- package/src/platforms/gba/lib/libgba/include/mappy.h +72 -0
- package/src/platforms/gba/lib/libgba/include/mbv2.h +90 -0
- package/src/platforms/gba/lib/libgba/include/xcomms.h +93 -0
- package/src/platforms/gba/lib/libgba/include/xcomms_cmd.h +53 -0
- package/src/platforms/gba/lib/libgba/libgba.seed.a +0 -0
- package/src/platforms/gba/lib/libgba/libgba.seed.hash +1 -0
- package/src/platforms/gba/lib/libgba/src/AffineSet.c +42 -0
- package/src/platforms/gba/lib/libgba/src/ArcTan.s +41 -0
- package/src/platforms/gba/lib/libgba/src/BoyScout/BoyScout.c +1242 -0
- package/src/platforms/gba/lib/libgba/src/BoyScout/GBASoundRegs.h +200 -0
- package/src/platforms/gba/lib/libgba/src/Compression.c +84 -0
- package/src/platforms/gba/lib/libgba/src/CpuSet.c +41 -0
- package/src/platforms/gba/lib/libgba/src/Div.s +58 -0
- package/src/platforms/gba/lib/libgba/src/DivArm.s +50 -0
- package/src/platforms/gba/lib/libgba/src/InterruptDispatcher.s +113 -0
- package/src/platforms/gba/lib/libgba/src/IntrWait.c +35 -0
- package/src/platforms/gba/lib/libgba/src/MultiBoot.s +33 -0
- package/src/platforms/gba/lib/libgba/src/Reset.s +49 -0
- package/src/platforms/gba/lib/libgba/src/Sound.s +48 -0
- package/src/platforms/gba/lib/libgba/src/Sqrt.s +34 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/disc.c +58 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/dldi.c +189 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/dldi_stub.s +78 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_cf_common.c +260 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_cf_common.h +72 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_m3_common.c +60 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_m3_common.h +48 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_m3cf.c +83 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_m3cf.h +45 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_m3sd.c +508 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_m3sd.h +45 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_mpcf.c +87 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_mpcf.h +42 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_sc_common.c +47 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_sc_common.h +43 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_sccf.c +83 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_sccf.h +45 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_scsd.c +385 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_scsd.h +48 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_scsd_s.s +139 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_sd_common.c +203 -0
- package/src/platforms/gba/lib/libgba/src/disc_io/io_sd_common.h +108 -0
- package/src/platforms/gba/lib/libgba/src/fade.c +185 -0
- package/src/platforms/gba/lib/libgba/src/input.c +127 -0
- package/src/platforms/gba/lib/libgba/src/interrupt.c +116 -0
- package/src/platforms/gba/lib/libgba/src/mappy_print.c +74 -0
- package/src/platforms/gba/lib/libgba/src/mb2print.c +69 -0
- package/src/platforms/gba/lib/libgba/src/mbv2.c +230 -0
- package/src/platforms/gba/lib/libgba/src/mbv2.txt +119 -0
- package/src/platforms/gba/lib/libgba/src/xcomms.c +203 -0
- package/src/platforms/gba/lib/libgba/src/xcomms_print.c +56 -0
- package/src/platforms/gba/lib/libgba/sysinclude/_ansi.h +82 -0
- package/src/platforms/gba/lib/libgba/sysinclude/_newlib_version.h +11 -0
- package/src/platforms/gba/lib/libgba/sysinclude/_syslist.h +41 -0
- package/src/platforms/gba/lib/libgba/sysinclude/alloca.h +21 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ar.h +65 -0
- package/src/platforms/gba/lib/libgba/sysinclude/argz.h +33 -0
- package/src/platforms/gba/lib/libgba/sysinclude/assert.h +50 -0
- package/src/platforms/gba/lib/libgba/sysinclude/complex.h +150 -0
- package/src/platforms/gba/lib/libgba/sysinclude/cpio.h +30 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ctype.h +183 -0
- package/src/platforms/gba/lib/libgba/sysinclude/devctl.h +78 -0
- package/src/platforms/gba/lib/libgba/sysinclude/dirent.h +85 -0
- package/src/platforms/gba/lib/libgba/sysinclude/elf.h +3147 -0
- package/src/platforms/gba/lib/libgba/sysinclude/envlock.h +15 -0
- package/src/platforms/gba/lib/libgba/sysinclude/envz.h +16 -0
- package/src/platforms/gba/lib/libgba/sysinclude/errno.h +11 -0
- package/src/platforms/gba/lib/libgba/sysinclude/fastmath.h +13 -0
- package/src/platforms/gba/lib/libgba/sysinclude/fcntl.h +1 -0
- package/src/platforms/gba/lib/libgba/sysinclude/fenv.h +42 -0
- package/src/platforms/gba/lib/libgba/sysinclude/float.h +631 -0
- package/src/platforms/gba/lib/libgba/sysinclude/fnmatch.h +55 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ftw.h +66 -0
- package/src/platforms/gba/lib/libgba/sysinclude/getopt.h +185 -0
- package/src/platforms/gba/lib/libgba/sysinclude/glob.h +90 -0
- package/src/platforms/gba/lib/libgba/sysinclude/grp.h +86 -0
- package/src/platforms/gba/lib/libgba/sysinclude/iconv.h +63 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ieeefp.h +295 -0
- package/src/platforms/gba/lib/libgba/sysinclude/inttypes.h +345 -0
- package/src/platforms/gba/lib/libgba/sysinclude/iso646.h +45 -0
- package/src/platforms/gba/lib/libgba/sysinclude/langinfo.h +332 -0
- package/src/platforms/gba/lib/libgba/sysinclude/libgen.h +37 -0
- package/src/platforms/gba/lib/libgba/sysinclude/limits.h +168 -0
- package/src/platforms/gba/lib/libgba/sysinclude/locale.h +96 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/_arc4random.h +1 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/_default_types.h +250 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/_endian.h +39 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/_time.h +3 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/_types.h +8 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/ansi.h +1 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/endian.h +69 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/fastmath.h +98 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/ieee.h +127 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/ieeefp.h +533 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/malloc.h +8 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/param.h +8 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/setjmp-dj.h +43 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/setjmp.h +524 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/stdlib.h +8 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/termios.h +1 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/time.h +15 -0
- package/src/platforms/gba/lib/libgba/sysinclude/machine/types.h +13 -0
- package/src/platforms/gba/lib/libgba/sysinclude/malloc.h +173 -0
- package/src/platforms/gba/lib/libgba/sysinclude/math.h +645 -0
- package/src/platforms/gba/lib/libgba/sysinclude/memory.h +4 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ndbm.h +91 -0
- package/src/platforms/gba/lib/libgba/sysinclude/newlib.h +427 -0
- package/src/platforms/gba/lib/libgba/sysinclude/paths.h +9 -0
- package/src/platforms/gba/lib/libgba/sysinclude/pthread.h +456 -0
- package/src/platforms/gba/lib/libgba/sysinclude/pwd.h +83 -0
- package/src/platforms/gba/lib/libgba/sysinclude/reent.h +190 -0
- package/src/platforms/gba/lib/libgba/sysinclude/regdef.h +7 -0
- package/src/platforms/gba/lib/libgba/sysinclude/regex.h +103 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sched.h +112 -0
- package/src/platforms/gba/lib/libgba/sysinclude/search.h +64 -0
- package/src/platforms/gba/lib/libgba/sysinclude/setjmp.h +25 -0
- package/src/platforms/gba/lib/libgba/sysinclude/signal.h +35 -0
- package/src/platforms/gba/lib/libgba/sysinclude/spawn.h +111 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ssp/ssp.h +76 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ssp/stdio.h +101 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ssp/stdlib.h +30 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ssp/string.h +115 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ssp/strings.h +55 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ssp/unistd.h +93 -0
- package/src/platforms/gba/lib/libgba/sysinclude/ssp/wchar.h +97 -0
- package/src/platforms/gba/lib/libgba/sysinclude/stdarg.h +135 -0
- package/src/platforms/gba/lib/libgba/sysinclude/stdatomic.h +409 -0
- package/src/platforms/gba/lib/libgba/sysinclude/stdbool.h +51 -0
- package/src/platforms/gba/lib/libgba/sysinclude/stddef.h +463 -0
- package/src/platforms/gba/lib/libgba/sysinclude/stdint.h +466 -0
- package/src/platforms/gba/lib/libgba/sysinclude/stdio.h +807 -0
- package/src/platforms/gba/lib/libgba/sysinclude/stdio_ext.h +79 -0
- package/src/platforms/gba/lib/libgba/sysinclude/stdlib.h +345 -0
- package/src/platforms/gba/lib/libgba/sysinclude/string.h +183 -0
- package/src/platforms/gba/lib/libgba/sysinclude/strings.h +80 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_default_fcntl.h +241 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_intsup.h +199 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_locale.h +12 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_pthreadtypes.h +233 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_sigset.h +43 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_stdint.h +90 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_timespec.h +52 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_timeval.h +60 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_types.h +228 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/_tz_structs.h +24 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/cdefs.h +754 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/config.h +314 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/custom_file.h +2 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/dir.h +10 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/dirent.h +13 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/endian.h +207 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/errno.h +198 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/fcntl.h +12 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/features.h +551 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/fenv.h +90 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/file.h +2 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/iconvnls.h +77 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/iosupport.h +143 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/lock.h +75 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/param.h +35 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/queue.h +919 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/reent.h +913 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/resource.h +24 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/sched.h +69 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/select.h +94 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/signal.h +388 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/stat.h +179 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/statvfs.h +41 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/stdio.h +27 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/string.h +2 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/syslimits.h +61 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/time.h +448 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/timeb.h +40 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/times.h +32 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/timespec.h +63 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/tree.h +864 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/types.h +228 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/unistd.h +591 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/utime.h +22 -0
- package/src/platforms/gba/lib/libgba/sysinclude/sys/wait.h +44 -0
- package/src/platforms/gba/lib/libgba/sysinclude/tar.h +43 -0
- package/src/platforms/gba/lib/libgba/sysinclude/termios.h +7 -0
- package/src/platforms/gba/lib/libgba/sysinclude/tgmath.h +127 -0
- package/src/platforms/gba/lib/libgba/sysinclude/threads.h +93 -0
- package/src/platforms/gba/lib/libgba/sysinclude/time.h +313 -0
- package/src/platforms/gba/lib/libgba/sysinclude/unctrl.h +42 -0
- package/src/platforms/gba/lib/libgba/sysinclude/unistd.h +6 -0
- package/src/platforms/gba/lib/libgba/sysinclude/utime.h +12 -0
- package/src/platforms/gba/lib/libgba/sysinclude/utmp.h +8 -0
- package/src/platforms/gba/lib/libgba/sysinclude/varargs.h +7 -0
- package/src/platforms/gba/lib/libgba/sysinclude/wchar.h +339 -0
- package/src/platforms/gba/lib/libgba/sysinclude/wctype.h +74 -0
- package/src/platforms/gba/lib/libgba/sysinclude/wordexp.h +53 -0
- package/src/platforms/gba/lib/libtonc/crtbegin.o +0 -0
- package/src/platforms/gba/lib/libtonc/crtend.o +0 -0
- package/src/platforms/gba/lib/libtonc/crti.o +0 -0
- package/src/platforms/gba/lib/libtonc/crtn.o +0 -0
- package/src/platforms/gba/lib/libtonc/gba_cart.ld +319 -0
- package/src/platforms/gba/lib/libtonc/gba_crt0.s +258 -0
- package/src/platforms/gba/lib/libtonc/include/tonc.h +72 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_asminc.h +132 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_bios.h +555 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_core.h +573 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_input.h +184 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_irq.h +121 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_legacy.h +481 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_libgba.h +537 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_math.h +692 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_memdef.h +962 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_memmap.h +583 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_nocash.h +51 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_oam.h +186 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_surface.h +461 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_text.h +270 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_tte.h +748 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_types.h +376 -0
- package/src/platforms/gba/lib/libtonc/include/tonc_video.h +615 -0
- package/src/platforms/gba/lib/libtonc/libtonc.seed.a +0 -0
- package/src/platforms/gba/lib/libtonc/libtonc.seed.hash +1 -0
- package/src/platforms/gba/lib/libtonc/src/asm/clr_blend_fast.s +72 -0
- package/src/platforms/gba/lib/libtonc/src/asm/clr_fade_fast.s +74 -0
- package/src/platforms/gba/lib/libtonc/src/asm/div_lut.s +54 -0
- package/src/platforms/gba/lib/libtonc/src/asm/sin_lut.s +90 -0
- package/src/platforms/gba/lib/libtonc/src/asm/tonc_bios.s +289 -0
- package/src/platforms/gba/lib/libtonc/src/asm/tonc_bios_ex.s +97 -0
- package/src/platforms/gba/lib/libtonc/src/asm/tonc_isr_master.s +92 -0
- package/src/platforms/gba/lib/libtonc/src/asm/tonc_isr_nest.s +98 -0
- package/src/platforms/gba/lib/libtonc/src/asm/tonc_memcpy.s +126 -0
- package/src/platforms/gba/lib/libtonc/src/asm/tonc_memset.s +123 -0
- package/src/platforms/gba/lib/libtonc/src/asm/tonc_nocash.s +73 -0
- package/src/platforms/gba/lib/libtonc/src/font/sys8.png +0 -0
- package/src/platforms/gba/lib/libtonc/src/font/sys8.s +46 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana10.png +0 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana10.s +293 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana9.png +0 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana9.s +167 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana9_b4.png +0 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana9_b4.s +545 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana9b.png +0 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana9b.s +167 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana9i.png +0 -0
- package/src/platforms/gba/lib/libtonc/src/font/verdana9i.s +167 -0
- package/src/platforms/gba/lib/libtonc/src/pre1.3/tonc_bitmap.c +289 -0
- package/src/platforms/gba/lib/libtonc/src/pre1.3/tonc_text.c +81 -0
- package/src/platforms/gba/lib/libtonc/src/pre1.3/tonc_text_bm.c +244 -0
- package/src/platforms/gba/lib/libtonc/src/pre1.3/tonc_text_map.c +122 -0
- package/src/platforms/gba/lib/libtonc/src/pre1.3/tonc_text_oam.c +113 -0
- package/src/platforms/gba/lib/libtonc/src/pre1.3/toncfont.s +43 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_bg.c +61 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_bg_affine.c +112 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_bmp16.c +240 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_bmp8.c +314 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_color.c +368 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_core.c +237 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_input.c +118 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_irq.c +271 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_math.c +54 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_oam.c +76 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_obj_affine.c +146 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_sbmp16.c +369 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_sbmp8.c +405 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_schr4c.c +588 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_schr4r.c +462 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_surface.c +105 -0
- package/src/platforms/gba/lib/libtonc/src/tonc_video.c +33 -0
- package/src/platforms/gba/lib/libtonc/src/tte/ase_drawg.c +83 -0
- package/src/platforms/gba/lib/libtonc/src/tte/bmp16_drawg.c +72 -0
- package/src/platforms/gba/lib/libtonc/src/tte/bmp16_drawg_b1cs.c +92 -0
- package/src/platforms/gba/lib/libtonc/src/tte/bmp8_drawg.c +71 -0
- package/src/platforms/gba/lib/libtonc/src/tte/bmp8_drawg_b1cs.c +104 -0
- package/src/platforms/gba/lib/libtonc/src/tte/bmp8_drawg_b1cts_fast.s +115 -0
- package/src/platforms/gba/lib/libtonc/src/tte/chr4c_drawg_b1cts.c +76 -0
- package/src/platforms/gba/lib/libtonc/src/tte/chr4c_drawg_b1cts_fast.s +128 -0
- package/src/platforms/gba/lib/libtonc/src/tte/chr4c_drawg_b4cts.c +67 -0
- package/src/platforms/gba/lib/libtonc/src/tte/chr4c_drawg_b4cts_fast.s +127 -0
- package/src/platforms/gba/lib/libtonc/src/tte/chr4r_drawg_b1cts.c +80 -0
- package/src/platforms/gba/lib/libtonc/src/tte/chr4r_drawg_b1cts_fast.s +145 -0
- package/src/platforms/gba/lib/libtonc/src/tte/obj_drawg.c +61 -0
- package/src/platforms/gba/lib/libtonc/src/tte/se_drawg.c +110 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_init_ase.c +87 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_init_bmp.c +118 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_init_chr4c.c +86 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_init_chr4r.c +87 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_init_obj.c +84 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_init_se.c +96 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_iohook.c +264 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_main.c +756 -0
- package/src/platforms/gba/lib/libtonc/src/tte/tte_types.s +119 -0
- package/src/platforms/gba/lib/maxmod/LICENSE-MAXMOD +23 -0
- package/src/platforms/gba/lib/maxmod/asm_include/mp_defs.inc +117 -0
- package/src/platforms/gba/lib/maxmod/asm_include/mp_format_mas.inc +108 -0
- package/src/platforms/gba/lib/maxmod/asm_include/mp_macros.inc +195 -0
- package/src/platforms/gba/lib/maxmod/asm_include/mp_mas.inc +40 -0
- package/src/platforms/gba/lib/maxmod/asm_include/mp_mas_structs.inc +189 -0
- package/src/platforms/gba/lib/maxmod/asm_include/mp_mixer_ds.inc +46 -0
- package/src/platforms/gba/lib/maxmod/asm_include/mp_mixer_gba.inc +42 -0
- package/src/platforms/gba/lib/maxmod/asm_include/swi_gba.inc +23 -0
- package/src/platforms/gba/lib/maxmod/include/maxmod.h +412 -0
- package/src/platforms/gba/lib/maxmod/include/mm_types.h +333 -0
- package/src/platforms/gba/lib/maxmod/maxmod.seed.a +0 -0
- package/src/platforms/gba/lib/maxmod/maxmod.seed.hash +1 -0
- package/src/platforms/gba/lib/maxmod/music/chiptune.xm +0 -0
- package/src/platforms/gba/lib/maxmod/music/chiptune_soundbank.bin +0 -0
- package/src/platforms/gba/lib/maxmod/music/chiptune_soundbank.h +4 -0
- package/src/platforms/gba/lib/maxmod/music/make_chiptune_xm.js +203 -0
- package/src/platforms/gba/lib/maxmod/source/mm_effect.s +767 -0
- package/src/platforms/gba/lib/maxmod/source/mm_main.s +115 -0
- package/src/platforms/gba/lib/maxmod/source/mm_mas.s +4990 -0
- package/src/platforms/gba/lib/maxmod/source/mm_mas_arm.s +612 -0
- package/src/platforms/gba/lib/maxmod/source_gba/mm_init_default.s +98 -0
- package/src/platforms/gba/lib/maxmod/source_gba/mm_main_gba.s +292 -0
- package/src/platforms/gba/lib/maxmod/source_gba/mm_mixer_gba.s +1367 -0
- package/src/platforms/gba/lib/sysbase/gba_iosupport.c +138 -0
- package/src/platforms/gbc/MENTAL_MODEL.md +165 -0
- package/src/platforms/gbc/TROUBLESHOOTING.md +142 -0
- package/src/platforms/gbc/UPSTREAM_SOURCES.md +60 -0
- package/src/platforms/gbc/lib/c/LICENSE-HUGEDRIVER +25 -0
- package/src/platforms/gbc/lib/c/README.md +120 -0
- package/src/platforms/gbc/lib/c/SDCC_GOTCHAS.md +189 -0
- package/src/platforms/gbc/lib/c/gb_crt0.s +163 -0
- package/src/platforms/gbc/lib/c/gb_hardware.h +113 -0
- package/src/platforms/gbc/lib/c/gb_runtime.c +284 -0
- package/src/platforms/gbc/lib/c/gb_runtime.h +145 -0
- package/src/platforms/gbc/lib/c/hUGEDriver.c +191 -0
- package/src/platforms/gbc/lib/c/hUGEDriver.h +95 -0
- package/src/platforms/gbc/lib/c/hUGEDriver.upstream.asm +1908 -0
- package/src/platforms/gbc/lib/c/lcd_init.c +19 -0
- package/src/platforms/gbc/lib/c/patch-header.js +154 -0
- package/src/platforms/gbc/lib/c/song_data.c +88 -0
- package/src/platforms/gbc/lib/c/unroll.h +52 -0
- package/src/platforms/gbc/lib/c/wait_vblank.c +14 -0
- package/src/platforms/genesis/MENTAL_MODEL.md +223 -0
- package/src/platforms/genesis/TROUBLESHOOTING.md +193 -0
- package/src/platforms/genesis/UPSTREAM_SOURCES.md +52 -0
- package/src/platforms/genesis/image-to-tilemap.js +333 -0
- package/src/platforms/genesis/lib/README.md +157 -0
- package/src/platforms/genesis/lib/c/crtbegin.o +0 -0
- package/src/platforms/genesis/lib/c/crtend.o +0 -0
- package/src/platforms/genesis/lib/c/genesis.ld +44 -0
- package/src/platforms/genesis/lib/c/genesis_sfx.c +51 -0
- package/src/platforms/genesis/lib/c/genesis_sfx.h +49 -0
- package/src/platforms/genesis/lib/c/libc.a +0 -0
- package/src/platforms/genesis/lib/c/libgcc.a +0 -0
- package/src/platforms/genesis/lib/c/libm.a +0 -0
- package/src/platforms/genesis/lib/c/sega.s +71 -0
- package/src/platforms/genesis/lib/header.s +96 -0
- package/src/platforms/genesis/lib/nmi_safe.s +79 -0
- package/src/platforms/genesis/lib/pad_read.s +104 -0
- package/src/platforms/genesis/lib/sgdk/COPYING.RUNTIME +73 -0
- package/src/platforms/genesis/lib/sgdk/LICENSE +12 -0
- package/src/platforms/genesis/lib/sgdk/include/asm.h +52 -0
- package/src/platforms/genesis/lib/sgdk/include/asm_mac.i +9 -0
- package/src/platforms/genesis/lib/sgdk/include/bmp.h +690 -0
- package/src/platforms/genesis/lib/sgdk/include/config.h +208 -0
- package/src/platforms/genesis/lib/sgdk/include/dma.h +542 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/console.h +387 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/everdrive.h +116 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/fat16.h +84 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/flash-save/flash.h +164 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/flash-save/saveman.h +177 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/link_cable.h +316 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/minimusic/minimus.h +29 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/16c550.h +221 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/comm.h +93 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/gamejolt.h +541 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/jsmn.h +471 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/json.h +122 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/lsd.h +172 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/megawifi.h +984 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/mw-msg.h +392 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/ssf_ed_pro.h +38 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/mw/ssf_ed_x7.h +73 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/serial/buffer.h +8 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/serial/serial.h +133 -0
- package/src/platforms/genesis/lib/sgdk/include/ext/stb/stb_sprintf.h +1864 -0
- package/src/platforms/genesis/lib/sgdk/include/genesis.h +92 -0
- package/src/platforms/genesis/lib/sgdk/include/joy.h +482 -0
- package/src/platforms/genesis/lib/sgdk/include/kdebug.h +21 -0
- package/src/platforms/genesis/lib/sgdk/include/map.h +409 -0
- package/src/platforms/genesis/lib/sgdk/include/mapper.h +186 -0
- package/src/platforms/genesis/lib/sgdk/include/maths.h +1071 -0
- package/src/platforms/genesis/lib/sgdk/include/maths3D.h +480 -0
- package/src/platforms/genesis/lib/sgdk/include/memory.h +346 -0
- package/src/platforms/genesis/lib/sgdk/include/memory_base.h +37 -0
- package/src/platforms/genesis/lib/sgdk/include/object.h +171 -0
- package/src/platforms/genesis/lib/sgdk/include/pal.h +500 -0
- package/src/platforms/genesis/lib/sgdk/include/pool.h +171 -0
- package/src/platforms/genesis/lib/sgdk/include/psg.h +153 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/pcm/snd_dpcm2.h +79 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/pcm/snd_pcm.h +98 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/pcm/snd_pcm4.h +125 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/pcm/tab_vol.h +6 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/smp_null.h +6 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/smp_null_dpcm.h +6 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/sound.h +70 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/xgm.h +399 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/xgm2.h +389 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/z80_def.i80 +41 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/z80_fct.i80 +83 -0
- package/src/platforms/genesis/lib/sgdk/include/snd/z80_mac.i80 +1476 -0
- package/src/platforms/genesis/lib/sgdk/include/sprite_eng.h +1095 -0
- package/src/platforms/genesis/lib/sgdk/include/sprite_eng_legacy.h +1030 -0
- package/src/platforms/genesis/lib/sgdk/include/sram.h +110 -0
- package/src/platforms/genesis/lib/sgdk/include/string.h +349 -0
- package/src/platforms/genesis/lib/sgdk/include/sys.h +511 -0
- package/src/platforms/genesis/lib/sgdk/include/tab_cnv.h +19 -0
- package/src/platforms/genesis/lib/sgdk/include/task.h +77 -0
- package/src/platforms/genesis/lib/sgdk/include/task_cst.h +33 -0
- package/src/platforms/genesis/lib/sgdk/include/timer.h +132 -0
- package/src/platforms/genesis/lib/sgdk/include/tools.h +450 -0
- package/src/platforms/genesis/lib/sgdk/include/types.h +320 -0
- package/src/platforms/genesis/lib/sgdk/include/vdp.h +1150 -0
- package/src/platforms/genesis/lib/sgdk/include/vdp_bg.h +723 -0
- package/src/platforms/genesis/lib/sgdk/include/vdp_pal.h +101 -0
- package/src/platforms/genesis/lib/sgdk/include/vdp_spr.h +448 -0
- package/src/platforms/genesis/lib/sgdk/include/vdp_tile.h +1136 -0
- package/src/platforms/genesis/lib/sgdk/include/vram.h +270 -0
- package/src/platforms/genesis/lib/sgdk/include/ym2612.h +87 -0
- package/src/platforms/genesis/lib/sgdk/include/z80_ctrl.h +420 -0
- package/src/platforms/genesis/lib/sgdk/libmd.seed.a +0 -0
- package/src/platforms/genesis/lib/sgdk/libmd.seed.hash +1 -0
- package/src/platforms/genesis/lib/sgdk/md.ld +120 -0
- package/src/platforms/genesis/lib/sgdk/music/demo.vgm +0 -0
- package/src/platforms/genesis/lib/sgdk/music/demo.xgc +0 -0
- package/src/platforms/genesis/lib/sgdk/music/demo.xgm +0 -0
- package/src/platforms/genesis/lib/sgdk/res/image/font_default.png +0 -0
- package/src/platforms/genesis/lib/sgdk/res/image/sgdk_logo.png +0 -0
- package/src/platforms/genesis/lib/sgdk/res/libres.h +10 -0
- package/src/platforms/genesis/lib/sgdk/res/libres.res +5 -0
- package/src/platforms/genesis/lib/sgdk/res/libres.s +166 -0
- package/src/platforms/genesis/lib/sgdk/res/sound/stop_xgm.bin +0 -0
- package/src/platforms/genesis/lib/sgdk/rom_header.c +33 -0
- package/src/platforms/genesis/lib/sgdk/sega.preprocessed.s +364 -0
- package/src/platforms/genesis/lib/sgdk/sega.s +365 -0
- package/src/platforms/genesis/lib/sgdk/src/bmp.c +1539 -0
- package/src/platforms/genesis/lib/sgdk/src/bmp_a.s +3477 -0
- package/src/platforms/genesis/lib/sgdk/src/boot/rom_header.c +33 -0
- package/src/platforms/genesis/lib/sgdk/src/boot/sega.s +365 -0
- package/src/platforms/genesis/lib/sgdk/src/dma.c +782 -0
- package/src/platforms/genesis/lib/sgdk/src/dma_a.s +23 -0
- package/src/platforms/genesis/lib/sgdk/src/error_a.s +376 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/console.c +490 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/everdrive.c +285 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/fat16.c +610 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/flash-save/README.md +112 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/flash-save/flash.c +300 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/flash-save/saveman.c +641 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/link_cable.c +1758 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/CHANGELOG.md +31 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/LICENSE.txt +17 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/README.md +18 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/data.z80 +148 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/define.z80 +173 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/doc/api-c.md +80 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/doc/format.md +132 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/doc/teradrive.md +33 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/fm.z80 +363 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/main.z80 +433 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/minimus.c +129 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/minimus_drv.s80 +17 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/psg.z80 +231 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/track.z80 +398 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/minimusic/util.z80 +98 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/16c550.c +84 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/README.md +849 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/comm.c +141 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/gamejolt.c +758 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/json.c +153 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/lsd.c +364 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/megawifi.c +1501 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/ssf_ed_pro.c +98 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/mw/ssf_ed_x7.c +67 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/serial/buffer.c +69 -0
- package/src/platforms/genesis/lib/sgdk/src/ext/serial/serial.c +158 -0
- package/src/platforms/genesis/lib/sgdk/src/joy.c +1361 -0
- package/src/platforms/genesis/lib/sgdk/src/kdebug.s +109 -0
- package/src/platforms/genesis/lib/sgdk/src/map.c +1915 -0
- package/src/platforms/genesis/lib/sgdk/src/mapper.c +280 -0
- package/src/platforms/genesis/lib/sgdk/src/maths.c +878 -0
- package/src/platforms/genesis/lib/sgdk/src/maths3D.c +480 -0
- package/src/platforms/genesis/lib/sgdk/src/maths3D_a.s +205 -0
- package/src/platforms/genesis/lib/sgdk/src/memory.c +760 -0
- package/src/platforms/genesis/lib/sgdk/src/memory_a.s +306 -0
- package/src/platforms/genesis/lib/sgdk/src/object.c +111 -0
- package/src/platforms/genesis/lib/sgdk/src/pal.c +484 -0
- package/src/platforms/genesis/lib/sgdk/src/pool.c +234 -0
- package/src/platforms/genesis/lib/sgdk/src/psg.c +82 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/drv_null.s80 +27 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/drv_xgm.s80 +3037 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/pcm/drv_dpcm2.s80 +984 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/pcm/drv_pcm.s80 +592 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/pcm/drv_pcm4.s80 +699 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/pcm/snd_dpcm2.c +172 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/pcm/snd_pcm.c +152 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/pcm/snd_pcm4.c +213 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/pcm/tab_vol.c +277 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/smp_null.s +22 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/smp_null_dpcm.s +15 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/sound.c +33 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm.c +683 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2.s80 +993 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2_fct.i80 +611 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2_mac.i80 +133 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2_pcm_fct.i80 +114 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2_pcm_mac.i80 +1444 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2_psg_fct.i80 +491 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2_psg_mac.i80 +43 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2_ym_fct.i80 +1664 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2/drv_xgm2_ym_mac.i80 +295 -0
- package/src/platforms/genesis/lib/sgdk/src/snd/xgm2.c +1083 -0
- package/src/platforms/genesis/lib/sgdk/src/sprite_eng.c +2256 -0
- package/src/platforms/genesis/lib/sgdk/src/sprite_eng_legacy.c +2309 -0
- package/src/platforms/genesis/lib/sgdk/src/sram.c +30 -0
- package/src/platforms/genesis/lib/sgdk/src/sram_a.s +41 -0
- package/src/platforms/genesis/lib/sgdk/src/string.c +720 -0
- package/src/platforms/genesis/lib/sgdk/src/sys.c +1053 -0
- package/src/platforms/genesis/lib/sgdk/src/sys_a.s +74 -0
- package/src/platforms/genesis/lib/sgdk/src/tab_cnv.c +129 -0
- package/src/platforms/genesis/lib/sgdk/src/tab_log10.c +8201 -0
- package/src/platforms/genesis/lib/sgdk/src/tab_log2.c +8201 -0
- package/src/platforms/genesis/lib/sgdk/src/tab_sin.c +2058 -0
- package/src/platforms/genesis/lib/sgdk/src/tab_sqrt.c +8201 -0
- package/src/platforms/genesis/lib/sgdk/src/task.s +148 -0
- package/src/platforms/genesis/lib/sgdk/src/timer.c +201 -0
- package/src/platforms/genesis/lib/sgdk/src/tools.c +1299 -0
- package/src/platforms/genesis/lib/sgdk/src/tools_a.s +979 -0
- package/src/platforms/genesis/lib/sgdk/src/types.c +18 -0
- package/src/platforms/genesis/lib/sgdk/src/vdp.c +1060 -0
- package/src/platforms/genesis/lib/sgdk/src/vdp_bg.c +511 -0
- package/src/platforms/genesis/lib/sgdk/src/vdp_spr.c +322 -0
- package/src/platforms/genesis/lib/sgdk/src/vdp_tile.c +1011 -0
- package/src/platforms/genesis/lib/sgdk/src/vdp_tile_a.s +68 -0
- package/src/platforms/genesis/lib/sgdk/src/vram.c +273 -0
- package/src/platforms/genesis/lib/sgdk/src/ym2612.c +175 -0
- package/src/platforms/genesis/lib/sgdk/src/z80_ctrl.c +334 -0
- package/src/platforms/genesis/lib/sprite_table.s +129 -0
- package/src/platforms/genesis/lib/vblank_wait.s +73 -0
- package/src/platforms/genesis/lib/vdp_init.s +85 -0
- package/src/platforms/genesis/lib/wram.s +88 -0
- package/src/platforms/genesis/lib/z80_bootstrap.s +102 -0
- package/src/platforms/genesis/vdp.js +495 -0
- package/src/platforms/gg/MENTAL_MODEL.md +155 -0
- package/src/platforms/gg/TROUBLESHOOTING.md +91 -0
- package/src/platforms/gg/UPSTREAM_SOURCES.md +36 -0
- package/src/platforms/gg/lib/c/gg_crt0.s +112 -0
- package/src/platforms/gg/lib/c/gg_hw.h +62 -0
- package/src/platforms/gg/lib/c/gg_music.c +155 -0
- package/src/platforms/gg/lib/c/gg_music.h +89 -0
- package/src/platforms/gg/lib/c/gg_sfx.c +82 -0
- package/src/platforms/gg/lib/c/gg_sfx.h +40 -0
- package/src/platforms/gg/lib/c/joypad_read.c +22 -0
- package/src/platforms/gg/lib/c/load_palette.c +20 -0
- package/src/platforms/gg/lib/c/load_tiles.c +32 -0
- package/src/platforms/gg/lib/c/sprite_table.c +60 -0
- package/src/platforms/gg/lib/c/vblank_wait.c +10 -0
- package/src/platforms/gg/lib/c/vdp_init.c +58 -0
- package/src/platforms/index.js +7 -0
- package/src/platforms/lynx/MENTAL_MODEL.md +231 -0
- package/src/platforms/lynx/TROUBLESHOOTING.md +105 -0
- package/src/platforms/lynx/UPSTREAM_SOURCES.md +66 -0
- package/src/platforms/lynx/lib/c/lynx_music.c +63 -0
- package/src/platforms/lynx/lib/c/lynx_music.h +16 -0
- package/src/platforms/lynx/lib/c/lynx_sfx.c +147 -0
- package/src/platforms/lynx/lib/c/lynx_sfx.h +59 -0
- package/src/platforms/lynx/lib/cc65-src/bllhdr.s +18 -0
- package/src/platforms/lynx/lib/cc65-src/bootldr.s +195 -0
- package/src/platforms/lynx/lib/cc65-src/cgetc.s +69 -0
- package/src/platforms/lynx/lib/cc65-src/clock.s +87 -0
- package/src/platforms/lynx/lib/cc65-src/crt0.s +135 -0
- package/src/platforms/lynx/lib/cc65-src/defdir.s +29 -0
- package/src/platforms/lynx/lib/cc65-src/eeprom.s +255 -0
- package/src/platforms/lynx/lib/cc65-src/eeprom46.s +204 -0
- package/src/platforms/lynx/lib/cc65-src/eeprom66.s +227 -0
- package/src/platforms/lynx/lib/cc65-src/eeprom86.s +236 -0
- package/src/platforms/lynx/lib/cc65-src/exec.s +34 -0
- package/src/platforms/lynx/lib/cc65-src/exehdr.s +27 -0
- package/src/platforms/lynx/lib/cc65-src/extzp.inc +23 -0
- package/src/platforms/lynx/lib/cc65-src/extzp.s +30 -0
- package/src/platforms/lynx/lib/cc65-src/irq.s +45 -0
- package/src/platforms/lynx/lib/cc65-src/joy/lynx-stdjoy.s +93 -0
- package/src/platforms/lynx/lib/cc65-src/joy_stat_stddrv.s +14 -0
- package/src/platforms/lynx/lib/cc65-src/kbhit.s +56 -0
- package/src/platforms/lynx/lib/cc65-src/libref.s +9 -0
- package/src/platforms/lynx/lib/cc65-src/load.s +41 -0
- package/src/platforms/lynx/lib/cc65-src/lseek.s +58 -0
- package/src/platforms/lynx/lib/cc65-src/lynx-cart.s +98 -0
- package/src/platforms/lynx/lib/cc65-src/lynx-snd.s +1270 -0
- package/src/platforms/lynx/lib/cc65-src/mainargs.s +24 -0
- package/src/platforms/lynx/lib/cc65-src/open.s +136 -0
- package/src/platforms/lynx/lib/cc65-src/oserror.s +14 -0
- package/src/platforms/lynx/lib/cc65-src/read.s +44 -0
- package/src/platforms/lynx/lib/cc65-src/ser/lynx-comlynx.s +404 -0
- package/src/platforms/lynx/lib/cc65-src/ser_stat_stddrv.s +14 -0
- package/src/platforms/lynx/lib/cc65-src/sysuname.s +39 -0
- package/src/platforms/lynx/lib/cc65-src/tgi/lynx-160-102-16.s +1075 -0
- package/src/platforms/lynx/lib/cc65-src/tgi_colors.s +9 -0
- package/src/platforms/lynx/lib/cc65-src/tgi_irq.s +11 -0
- package/src/platforms/lynx/lib/cc65-src/tgi_stat_stddrv.s +14 -0
- package/src/platforms/lynx/lib/cc65-src/tgi_stddrv.s +13 -0
- package/src/platforms/lynx/lib/cc65-src/uploader.s +81 -0
- package/src/platforms/nes/MENTAL_MODEL.md +301 -0
- package/src/platforms/nes/TROUBLESHOOTING.md +321 -0
- package/src/platforms/nes/UPSTREAM_SOURCES.md +31 -0
- package/src/platforms/nes/image-to-chr.js +195 -0
- package/src/platforms/nes/image-to-tilemap.js +415 -0
- package/src/platforms/nes/lib/README.md +40 -0
- package/src/platforms/nes/lib/asm/LICENSE-FAMITONE +40 -0
- package/src/platforms/nes/lib/asm/chr_ram_header.s +32 -0
- package/src/platforms/nes/lib/asm/famitone2.s +1258 -0
- package/src/platforms/nes/lib/asm/famitone_bridge.s +50 -0
- package/src/platforms/nes/lib/asm/music_data.s +238 -0
- package/src/platforms/nes/lib/c/chr_ram_runtime_hello_sprite.c +81 -0
- package/src/platforms/nes/lib/c/chr_ram_runtime_hud_row.c +101 -0
- package/src/platforms/nes/lib/c/nes_runtime.c +347 -0
- package/src/platforms/nes/lib/c/nes_runtime.h +153 -0
- package/src/platforms/nes/lib/c/nmi_handler.c +51 -0
- package/src/platforms/nes/lib/c/nmi_trampoline.s +25 -0
- package/src/platforms/nes/lib/cc65-src/Makefile.inc +9 -0
- package/src/platforms/nes/lib/cc65-src/_scrsize.s +24 -0
- package/src/platforms/nes/lib/cc65-src/cclear.s +29 -0
- package/src/platforms/nes/lib/cc65-src/chline.s +31 -0
- package/src/platforms/nes/lib/cc65-src/clock.s +31 -0
- package/src/platforms/nes/lib/cc65-src/clrscr.s +72 -0
- package/src/platforms/nes/lib/cc65-src/color.s +68 -0
- package/src/platforms/nes/lib/cc65-src/cpeekc.s +37 -0
- package/src/platforms/nes/lib/cc65-src/cpeekcolor.s +8 -0
- package/src/platforms/nes/lib/cc65-src/cpeekrevers.s +37 -0
- package/src/platforms/nes/lib/cc65-src/cputc.s +95 -0
- package/src/platforms/nes/lib/cc65-src/crt0.s +180 -0
- package/src/platforms/nes/lib/cc65-src/cvline.s +31 -0
- package/src/platforms/nes/lib/cc65-src/get_tv.s +37 -0
- package/src/platforms/nes/lib/cc65-src/gotox.s +21 -0
- package/src/platforms/nes/lib/cc65-src/gotoxy.s +22 -0
- package/src/platforms/nes/lib/cc65-src/gotoy.s +22 -0
- package/src/platforms/nes/lib/cc65-src/irq.s +19 -0
- package/src/platforms/nes/lib/cc65-src/joy/nes-stdjoy.s +102 -0
- package/src/platforms/nes/lib/cc65-src/joy_stat_stddrv.s +14 -0
- package/src/platforms/nes/lib/cc65-src/libref.s +9 -0
- package/src/platforms/nes/lib/cc65-src/mainargs.s +24 -0
- package/src/platforms/nes/lib/cc65-src/neschar.s +4616 -0
- package/src/platforms/nes/lib/cc65-src/ppu.s +158 -0
- package/src/platforms/nes/lib/cc65-src/ppubuf.s +117 -0
- package/src/platforms/nes/lib/cc65-src/randomize.s +18 -0
- package/src/platforms/nes/lib/cc65-src/revers.s +27 -0
- package/src/platforms/nes/lib/cc65-src/setcursor.s +37 -0
- package/src/platforms/nes/lib/cc65-src/sysuname.s +39 -0
- package/src/platforms/nes/lib/cc65-src/tgi/nes-64-56-2.s +480 -0
- package/src/platforms/nes/lib/cc65-src/tgi_stat_stddrv.s +14 -0
- package/src/platforms/nes/lib/cc65-src/tgi_stddrv.s +13 -0
- package/src/platforms/nes/lib/cc65-src/waitvsync.s +18 -0
- package/src/platforms/nes/lib/cc65-src/wherex.s +19 -0
- package/src/platforms/nes/lib/cc65-src/wherey.s +19 -0
- package/src/platforms/nes/lib/clear_nametable.s +38 -0
- package/src/platforms/nes/lib/clear_oam.s +18 -0
- package/src/platforms/nes/lib/load_palette.s +31 -0
- package/src/platforms/nes/lib/nmi_safe.s +65 -0
- package/src/platforms/nes/lib/oam_dma.s +16 -0
- package/src/platforms/nes/lib/read_pad.s +46 -0
- package/src/platforms/nes/lib/reset.s +46 -0
- package/src/platforms/nes/lib/sprite_table_populate.s +75 -0
- package/src/platforms/nes/lib/wait_vblank.s +12 -0
- package/src/platforms/nes/palette.js +39 -0
- package/src/platforms/nes/ppu.js +372 -0
- package/src/platforms/sms/MENTAL_MODEL.md +267 -0
- package/src/platforms/sms/TROUBLESHOOTING.md +124 -0
- package/src/platforms/sms/UPSTREAM_SOURCES.md +29 -0
- package/src/platforms/sms/image-to-tilemap.js +260 -0
- package/src/platforms/sms/lib/README.md +117 -0
- package/src/platforms/sms/lib/c/joypad_read.c +33 -0
- package/src/platforms/sms/lib/c/load_palette.c +24 -0
- package/src/platforms/sms/lib/c/load_tiles.c +32 -0
- package/src/platforms/sms/lib/c/sms_crt0.s +101 -0
- package/src/platforms/sms/lib/c/sms_hw.h +53 -0
- package/src/platforms/sms/lib/c/sms_music.c +178 -0
- package/src/platforms/sms/lib/c/sms_music.h +50 -0
- package/src/platforms/sms/lib/c/sms_sfx.c +82 -0
- package/src/platforms/sms/lib/c/sms_sfx.h +40 -0
- package/src/platforms/sms/lib/c/sprite_table.c +60 -0
- package/src/platforms/sms/lib/c/vblank_wait.c +10 -0
- package/src/platforms/sms/lib/c/vdp_init.c +58 -0
- package/src/platforms/sms/lib/header.s +33 -0
- package/src/platforms/sms/lib/joypad_read.s +40 -0
- package/src/platforms/sms/lib/load_palette.s +30 -0
- package/src/platforms/sms/lib/load_tiles.s +50 -0
- package/src/platforms/sms/lib/sprite_table.s +44 -0
- package/src/platforms/sms/lib/vblank_wait.s +36 -0
- package/src/platforms/sms/lib/vdp_init.s +47 -0
- package/src/platforms/sms/vdp.js +530 -0
- package/src/platforms/snes/MENTAL_MODEL.md +275 -0
- package/src/platforms/snes/TROUBLESHOOTING.md +208 -0
- package/src/platforms/snes/UPSTREAM_SOURCES.md +50 -0
- package/src/platforms/snes/brr.js +208 -0
- package/src/platforms/snes/image-to-tilemap.js +227 -0
- package/src/platforms/snes/lib/audio/apu_blob.asm +228 -0
- package/src/platforms/snes/lib/audio/apu_blob.bin +0 -0
- package/src/platforms/snes/lib/audio/explosion.brr +0 -0
- package/src/platforms/snes/lib/audio/sample_bank.bin +0 -0
- package/src/platforms/snes/lib/audio/shoot.brr +0 -0
- package/src/platforms/snes/lib/audio/spc_driver.asm +241 -0
- package/src/platforms/snes/lib/audio_pipeline.asm +62 -0
- package/src/platforms/snes/lib/c/crt0.asm +125 -0
- package/src/platforms/snes/lib/c/hdr.asm +50 -0
- package/src/platforms/snes/lib/c/snes_sfx.c +116 -0
- package/src/platforms/snes/lib/c/snes_sfx.h +96 -0
- package/src/platforms/snes/lib/c/snes_sfx_data.asm +25 -0
- package/src/platforms/snes/lib/cgram_upload.asm +43 -0
- package/src/platforms/snes/lib/lorom_header.asm +47 -0
- package/src/platforms/snes/lib/lorom_multibank.asm +66 -0
- package/src/platforms/snes/lib/nmi_safe.asm +77 -0
- package/src/platforms/snes/lib/oam_upload.asm +45 -0
- package/src/platforms/snes/lib/pad_read.asm +64 -0
- package/src/platforms/snes/lib/pvsneslib/LICENSE +21 -0
- package/src/platforms/snes/lib/pvsneslib/include/ctype.h +6 -0
- package/src/platforms/snes/lib/pvsneslib/include/float.h +4 -0
- package/src/platforms/snes/lib/pvsneslib/include/hdr.asm +47 -0
- package/src/platforms/snes/lib/pvsneslib/include/limits.h +13 -0
- package/src/platforms/snes/lib/pvsneslib/include/math.h +10 -0
- package/src/platforms/snes/lib/pvsneslib/include/setjmp.h +4 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/background.h +396 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/console.h +188 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/dma.h +381 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/input.h +289 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/interrupt.h +264 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/libversion.h +10 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/lzss.h +43 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/map.h +113 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/object.h +234 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/pixel.h +53 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/scores.h +66 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/snestypes.h +65 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/sound.h +245 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/sprite.h +456 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes/video.h +465 -0
- package/src/platforms/snes/lib/pvsneslib/include/snes.h +190 -0
- package/src/platforms/snes/lib/pvsneslib/include/stdarg.h +28 -0
- package/src/platforms/snes/lib/pvsneslib/include/stdbool.h +53 -0
- package/src/platforms/snes/lib/pvsneslib/include/stddef.h +27 -0
- package/src/platforms/snes/lib/pvsneslib/include/stdint.h +7 -0
- package/src/platforms/snes/lib/pvsneslib/include/stdio.h +9 -0
- package/src/platforms/snes/lib/pvsneslib/include/stdlib.h +13 -0
- package/src/platforms/snes/lib/pvsneslib/include/string.h +19 -0
- package/src/platforms/snes/lib/pvsneslib/include/strings.h +5 -0
- package/src/platforms/snes/lib/pvsneslib/source/Makefile +87 -0
- package/src/platforms/snes/lib/pvsneslib/source/backgrounds.asm +834 -0
- package/src/platforms/snes/lib/pvsneslib/source/consoles.asm +1028 -0
- package/src/platforms/snes/lib/pvsneslib/source/crt0_snes.asm +329 -0
- package/src/platforms/snes/lib/pvsneslib/source/dmas.asm +1275 -0
- package/src/platforms/snes/lib/pvsneslib/source/hdr.asm +56 -0
- package/src/platforms/snes/lib/pvsneslib/source/input.asm +445 -0
- package/src/platforms/snes/lib/pvsneslib/source/libc.asm +485 -0
- package/src/platforms/snes/lib/pvsneslib/source/libc_c.c +1214 -0
- package/src/platforms/snes/lib/pvsneslib/source/libm.asm +510 -0
- package/src/platforms/snes/lib/pvsneslib/source/libtcc.asm +374 -0
- package/src/platforms/snes/lib/pvsneslib/source/lzsss.asm +256 -0
- package/src/platforms/snes/lib/pvsneslib/source/maps.asm +1078 -0
- package/src/platforms/snes/lib/pvsneslib/source/objects.asm +2881 -0
- package/src/platforms/snes/lib/pvsneslib/source/scores.asm +226 -0
- package/src/platforms/snes/lib/pvsneslib/source/sm_spc.asm +187 -0
- package/src/platforms/snes/lib/pvsneslib/source/snesmodwla.asm +1186 -0
- package/src/platforms/snes/lib/pvsneslib/source/sounds.asm +273 -0
- package/src/platforms/snes/lib/pvsneslib/source/sprites.asm +3946 -0
- package/src/platforms/snes/lib/pvsneslib/source/vblank.asm +917 -0
- package/src/platforms/snes/lib/pvsneslib/source/videos.asm +1137 -0
- package/src/platforms/snes/lib/reset_init.asm +31 -0
- package/src/platforms/snes/lib/sprite_table_populate.asm +122 -0
- package/src/platforms/snes/lib/vram_dma_upload.asm +42 -0
- package/src/platforms/snes/ppu.js +606 -0
- package/src/playtest/playtest.js +612 -0
- package/src/rom-id/identifier.js +421 -0
- package/src/rom-id/patch.js +217 -0
- package/src/toolchains/_worker/pool.js +253 -0
- package/src/toolchains/_worker/run.js +78 -0
- package/src/toolchains/_worker/wasm-worker.js +233 -0
- package/src/toolchains/arm-none-eabi-gcc/gcc.js +208 -0
- package/src/toolchains/asar/asar.js +542 -0
- package/src/toolchains/assemble-snippet.js +256 -0
- package/src/toolchains/cc65/cc65.js +395 -0
- package/src/toolchains/cc65/da65.js +119 -0
- package/src/toolchains/cc65/dbgparse.js +274 -0
- package/src/toolchains/cc65/preset-resolver.js +59 -0
- package/src/toolchains/cc65/presets/nes/chr-ram-runtime.cfg +79 -0
- package/src/toolchains/cc65/presets/nes/chr-ram-runtime.crt0.s +178 -0
- package/src/toolchains/cc65/presets/nes/chr-ram.cfg +76 -0
- package/src/toolchains/cc65/presets/nes/chr-ram.crt0.s +106 -0
- package/src/toolchains/common/ar.js +121 -0
- package/src/toolchains/common/sdk-cache.js +116 -0
- package/src/toolchains/common/symbols.js +139 -0
- package/src/toolchains/dasm/dasm.js +96 -0
- package/src/toolchains/gba-c/gba-c.js +832 -0
- package/src/toolchains/genesis-c/README.md +61 -0
- package/src/toolchains/genesis-c/genesis-c.js +598 -0
- package/src/toolchains/index.js +727 -0
- package/src/toolchains/m68k-elf-gcc/gcc.js +220 -0
- package/src/toolchains/m68kdasm.js +438 -0
- package/src/toolchains/parse-errors.js +258 -0
- package/src/toolchains/registry.js +67 -0
- package/src/toolchains/rgbds/rgbds.js +144 -0
- package/src/toolchains/sdcc/preflight-lint.js +295 -0
- package/src/toolchains/sdcc/sdcc.js +519 -0
- package/src/toolchains/sjasm/sjasm.js +85 -0
- package/src/toolchains/sm83dasm.js +194 -0
- package/src/toolchains/snes-c/snes-c.js +409 -0
- package/src/toolchains/tcc816/tcc816.js +79 -0
- package/src/toolchains/vasm68k/vasm68k.js +138 -0
- package/src/toolchains/wladx/wladx.js +120 -0
- package/src/toolchains/z80dasm.js +303 -0
|
@@ -0,0 +1,1758 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Link Cable Protocol (LCP) - Protocol for data exchange via SEGA Link Cable
|
|
3
|
+
* between two Sega Mega Drive / Sega Genesis consoles connected through the second controller port
|
|
4
|
+
* for SGDK
|
|
5
|
+
*
|
|
6
|
+
* BlodTor 2025
|
|
7
|
+
*
|
|
8
|
+
* *************************************************************************************************
|
|
9
|
+
* *************************************************************************************************
|
|
10
|
+
* Master console function call sequence:
|
|
11
|
+
*
|
|
12
|
+
* 1) Initialize Link Cable Protocol.
|
|
13
|
+
* LCP_init();
|
|
14
|
+
*
|
|
15
|
+
* 2) Prepare data for transmission from master console via Link Cable Protocol.
|
|
16
|
+
* LCP_objectToPacketForSend(transferObject, objectType, objectTypeSizes);
|
|
17
|
+
* LCP_objectToPacketForSend(transferObject, objectType, objectTypeSizes);
|
|
18
|
+
* ...
|
|
19
|
+
* LCP_objectToPacketForSend(transferObject, objectType, objectTypeSizes);
|
|
20
|
+
*
|
|
21
|
+
* 3) Trigger external interrupt on slave console and send/receive data via Link Cable Protocol
|
|
22
|
+
* LCP_masterCycle();
|
|
23
|
+
*
|
|
24
|
+
* 4) Extract received objects from packet transmitted by slave console
|
|
25
|
+
* objectType = LCP_getNextObjectFromReceivePacket(transferObject, objectSizes);
|
|
26
|
+
* objectType = LCP_getNextObjectFromReceivePacket(transferObject, objectSizes);
|
|
27
|
+
* ...
|
|
28
|
+
* objectType = LCP_getNextObjectFromReceivePacket(transferObject, objectSizes);
|
|
29
|
+
* until objectType becomes 0
|
|
30
|
+
*
|
|
31
|
+
* 5) Close Link Cable Protocol if no further interaction with slave console is required.
|
|
32
|
+
* LCP_close();
|
|
33
|
+
*
|
|
34
|
+
* *************************************************************************************************
|
|
35
|
+
* *************************************************************************************************
|
|
36
|
+
* Slave console function call sequence:
|
|
37
|
+
*
|
|
38
|
+
* 1) Initialize Link Cable Protocol
|
|
39
|
+
* LCP_init();
|
|
40
|
+
*
|
|
41
|
+
* 2) Open port to enable slave console to handle external interrupts triggered by
|
|
42
|
+
* master console. Master console can only call LCP_slaveCycle() - the external
|
|
43
|
+
* interrupt handler on slave console - after this method is called.
|
|
44
|
+
* LCP_open();
|
|
45
|
+
*
|
|
46
|
+
* 3) Prepare data for transmission from slave console via Link Cable Protocol.
|
|
47
|
+
* Transmission occurs in LCP_slaveCycle() after receiving data from master console
|
|
48
|
+
* in this method. LCP_slaveCycle() is called asynchronously by suspending game code
|
|
49
|
+
* execution on slave console when external interrupt from LCP_masterCycle() method
|
|
50
|
+
* of master console occurs.
|
|
51
|
+
* LCP_objectToPacketForSend(transferObject, objectType, objectTypeSizes);
|
|
52
|
+
* LCP_objectToPacketForSend(transferObject, objectType, objectTypeSizes);
|
|
53
|
+
* ...
|
|
54
|
+
* LCP_objectToPacketForSend(transferObject, objectType, objectTypeSizes);
|
|
55
|
+
*
|
|
56
|
+
* 4) Extract received objects from packet transmitted by master console
|
|
57
|
+
* objectType = LCP_getNextObjectFromReceivePacket(transferObject, objectSizes);
|
|
58
|
+
* objectType = LCP_getNextObjectFromReceivePacket(transferObject, objectSizes);
|
|
59
|
+
* ...
|
|
60
|
+
* objectType = LCP_getNextObjectFromReceivePacket(transferObject, objectSizes);
|
|
61
|
+
* until objectType becomes 0
|
|
62
|
+
*
|
|
63
|
+
* 5) Close Link Cable Protocol if no further interaction with master console is required.
|
|
64
|
+
* Slave console will stop responding to external interrupts from master console!
|
|
65
|
+
* LCP_close();
|
|
66
|
+
*
|
|
67
|
+
* *************************************************************************************************
|
|
68
|
+
* *************************************************************************************************
|
|
69
|
+
* IMPORTANT USAGE NOTES:
|
|
70
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
71
|
+
*
|
|
72
|
+
* Object types (objectType) must be defined in YOUR game's main code!
|
|
73
|
+
* See constant declaration examples in 'Super Turbo MEGA Pac-Man 2.1' game code
|
|
74
|
+
* starting with 'OBJECT_TYPE_' prefix
|
|
75
|
+
*
|
|
76
|
+
* Object sizes (objectSizes) in bytes must be defined in YOUR game's main code!
|
|
77
|
+
* The protocol transfers 2 bytes of information per cycle, so there's no point in setting
|
|
78
|
+
* object lengths not multiples of 2 bytes! See constant declaration examples in
|
|
79
|
+
* 'Super Turbo MEGA Pac-Man 2.1' game code ending with '_OBJECT_LENGTH' postfix,
|
|
80
|
+
* as well as the LINK_TYPES_LENGHT array definition example which is passed as objectSizes
|
|
81
|
+
* parameter to LCP_objectToPacketForSend() and LCP_getNextObjectFromReceivePacket() functions
|
|
82
|
+
*
|
|
83
|
+
* Master/Slave console determination implementation must be in YOUR game's code!
|
|
84
|
+
* See initControllerPort2() function example in 'Super Turbo MEGA Pac-Man 2.1' game code
|
|
85
|
+
* which determines which of the two consoles becomes master and which becomes slave
|
|
86
|
+
*
|
|
87
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
88
|
+
*
|
|
89
|
+
* For debugging, use the function that returns transmission errors via SEGA Link Cable:
|
|
90
|
+
* LCP_getError()
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
#include "config.h"
|
|
95
|
+
|
|
96
|
+
#if (MODULE_LINK_CABLE != 0)
|
|
97
|
+
|
|
98
|
+
#include "ext/link_cable.h"
|
|
99
|
+
|
|
100
|
+
#include "types.h"
|
|
101
|
+
#include "sys.h"
|
|
102
|
+
#include "vdp.h"
|
|
103
|
+
#include "z80_ctrl.h"
|
|
104
|
+
#include "memory.h"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Global variables
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
// Port open or not (port CTRL 2 in SEGA documentation - second controller port)
|
|
112
|
+
//
|
|
113
|
+
// If 1 - open, external interrupt EX-INT (External Interrupt in SEGA documentation) should be triggered,
|
|
114
|
+
// initiated by another console which will be master relative to ours.
|
|
115
|
+
// I.e. we first receive data from the master console via port,
|
|
116
|
+
// then send data to it in one data exchange cycle.
|
|
117
|
+
//
|
|
118
|
+
// The interrupt handler can be called at any moment on our slave console.
|
|
119
|
+
// The executing code will be suspended at the moment of interrupt, and after the interrupt handler execution
|
|
120
|
+
// registers will be restored and main game code execution will continue.
|
|
121
|
+
//
|
|
122
|
+
// Data reception and transmission are asynchronous relative to preparation of what to send and processing of what
|
|
123
|
+
// was received by our slave console.
|
|
124
|
+
//
|
|
125
|
+
// If 0 - port closed, your console doesn't have EX-INT (External Interrupt) handler but can trigger
|
|
126
|
+
// this interrupt on another console, i.e. your console is master. We first send data to slave
|
|
127
|
+
// console, then receive data from it in one data exchange cycle.
|
|
128
|
+
//
|
|
129
|
+
// Data transmission and reception on our master console are synchronous, from main game code, relative to
|
|
130
|
+
// preparation of what to send and processing of what was received from another slave console
|
|
131
|
+
static u16 LCP_portOpen = 0;
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
// Start index of data in LCP_sendPacket array that needs to be transmitted via Link Cable
|
|
135
|
+
// Can transmit multiple objects, here will be the index of the first byte of the first
|
|
136
|
+
// untransmitted object in LCP_sendPacket packet
|
|
137
|
+
static u16 LCP_sendHead = 0;
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
// End index of data in LCP_sendPacket array that needs to be transmitted via Link Cable
|
|
141
|
+
// Can transmit multiple objects, here will be the last byte of the last
|
|
142
|
+
// untransmitted object in LCP_sendPacket packet
|
|
143
|
+
static u16 LCP_sendTail = 0;
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
// Data transmission packet - array where LCP_objectToPacketForSend function stores objects for transmission via Link Cable.
|
|
147
|
+
// This is done from the main loop of your game when something needs to be transmitted to another console.
|
|
148
|
+
// First 16 bits are the object type, followed by object data, and there can be multiple such objects in the packet.
|
|
149
|
+
//
|
|
150
|
+
// 0 LCP_sendHead LCP_sendTail LCP_PACKET_SIZE
|
|
151
|
+
// | 16 bits | | |
|
|
152
|
+
// [object type 1][object1][object type 2][object2][object type 3][object3][][][][][][][][][][][][][][]][][]][]
|
|
153
|
+
static u16 LCP_sendPacket[LCP_PACKET_SIZE];
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
// Start index of data in LCP_ReceivePacket array that was received via Link Cable
|
|
157
|
+
// Can receive multiple objects at once, here will be the index of the first byte of the first
|
|
158
|
+
// received object in LCP_ReceivePacket array
|
|
159
|
+
static u16 LCP_ReceiveHead = 0;
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
// End index of data in LCP_ReceivePacket array that was received via Link Cable
|
|
163
|
+
// Can receive multiple packets at once, here will be the last byte of the last
|
|
164
|
+
// received object in LCP_ReceivePacket array
|
|
165
|
+
static u16 LCP_ReceiveTail = 0;
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
// Received data packet - array from which LCP_getNextObjectFromReceivePacket function in your game's main code copies
|
|
169
|
+
// the next received object into transferObject (pointer to byte array in your game code) and returns the type of this object.
|
|
170
|
+
// This is done in your game's main code, while data gets into the packet during Master cycle work - LCP_masterCycle() for master console
|
|
171
|
+
// or Slave cycle work - LCP_slaveCycle() for slave console. These functions handle data transmission via Link Cable.
|
|
172
|
+
// LCP_masterCycle() - always called synchronously from your game's main code! And only on master console.
|
|
173
|
+
// LCP_slaveCycle() - called asynchronously upon external interrupt - External Interrupt (EX-INT) only on slave console.
|
|
174
|
+
//
|
|
175
|
+
// 0 LCP_ReceiveHead LCP_ReceiveTail LCP_PACKET_SIZE
|
|
176
|
+
// | 16 bits | | |
|
|
177
|
+
// [object type 1][object1][object type 2][object2][object type 3][object3][][][][][][][][][][][][][][]][][]][]
|
|
178
|
+
static u16 LCP_ReceivePacket[LCP_PACKET_SIZE];
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
// If non-zero, means there was a connection break during reception or transmission of lower 4 bits of LCP_Data
|
|
182
|
+
// and a data wait timeout occurred. What exactly happened can be understood from LCP_error.
|
|
183
|
+
static u8 LCP_timeOut = 0;
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
// Error in data transmission via SEGA Link Cable
|
|
187
|
+
//
|
|
188
|
+
// If 0x0000, no errors occurred! Value ranges in binary format
|
|
189
|
+
// Lower 4 bits of low byte - data reception errors via Link Cable (0x0001 - 0x000F) 000000000000xxxx
|
|
190
|
+
// Upper 4 bits of low byte - data transmission errors via Link Cable (0x0010 - 0x00F0) 00000000xxxx0000
|
|
191
|
+
// Lower 4 bits of high byte - packet reception or transmission errors (0x0100 - 0x0F00) 0000xxxx00000000
|
|
192
|
+
// Upper 4 bits of high byte - object extraction errors from packet (0x1000 - 0xF000) xxxx000000000000
|
|
193
|
+
static u16 LCP_error = 0;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Start of 2-byte (16-bit) data transfer cycle via Link Cable
|
|
197
|
+
* Reset bit 5 of LCP_Data to 0 - data not ready for reading by other console
|
|
198
|
+
* Set LCP_Ctrl = 00101111 to enable on controller port 2:
|
|
199
|
+
* pins 0-3 for data transmission, and pin 5 for signal that data can be read
|
|
200
|
+
* by other console. As soon as we set it to 1, we expect pin 6 to be 0
|
|
201
|
+
* at function call time (if it's 1, we'll wait for 0 until timeout occurs and throw error 0xA if not received)
|
|
202
|
+
*
|
|
203
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
204
|
+
* 0xA - data transmission preparation error (failed to get 0 on pin 6 of 2nd controller)
|
|
205
|
+
*
|
|
206
|
+
* If no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
207
|
+
*/
|
|
208
|
+
static void LCP_startSendCycle();
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Main 2-byte (16-bit) data transfer cycle via Link Cable
|
|
213
|
+
* Transmission is done through LCP_Data - shared memory area of both consoles
|
|
214
|
+
* 4 bits at a time, i.e. in 4 iterations since 2 bytes = 16 bits
|
|
215
|
+
* Fills the lower 4 data bits in LCP_Data that we're sending
|
|
216
|
+
* Sets or resets bit 5 depending on iteration in LCP_Data
|
|
217
|
+
* Waits for data reception confirmation from other console in bit 6 of LCP_Data
|
|
218
|
+
* If confirmation is not received, saves error in LCP_error
|
|
219
|
+
*
|
|
220
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
221
|
+
* 0x1 - failed to receive confirmation on 1st iteration
|
|
222
|
+
* 0x2 - failed to receive confirmation on 2nd iteration
|
|
223
|
+
* 0x3 - failed to receive confirmation on 3rd iteration
|
|
224
|
+
* 0x4 - failed to receive confirmation on 4th iteration
|
|
225
|
+
*
|
|
226
|
+
* data - 2 bytes of data (16 bits) to transmit
|
|
227
|
+
* Let's assume initial data = "aaaayyyybbbbxxxx" - split 2 bytes (16 bits) into 4-bit chunks:
|
|
228
|
+
* first transmit aaaa, then yyyy, then bbbb, and in 4th iteration xxxx
|
|
229
|
+
*
|
|
230
|
+
* At function call time LCP_Data = "r00rrrrr" - where r is any value and doesn't matter currently
|
|
231
|
+
* LCP_startSendCycle function must have completed successfully first, or another LCP_send must complete successfully
|
|
232
|
+
*
|
|
233
|
+
* If no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
234
|
+
*/
|
|
235
|
+
static void LCP_send(u16 data);
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* End of 2-byte (16-bit) data transfer cycle via Link Cable
|
|
240
|
+
* Set LCP_Ctrl = 00100000 to enable on controller port 2:
|
|
241
|
+
* pins 0-3 for data reception, and pin 5 for signal that our SEGA is ready to receive data.
|
|
242
|
+
* Reset bit 5 in LCP_Data to 0, wait for confirmation that other console is ready to send data -
|
|
243
|
+
* until bit 6 in LCP_Data becomes 1 or timeout occurs, and throw error 0xB if not received.
|
|
244
|
+
*
|
|
245
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
246
|
+
* 0xB - data transfer cycle end error (failed to get 1 in bit 6 of LCP_Data)
|
|
247
|
+
*
|
|
248
|
+
* If no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
249
|
+
*/
|
|
250
|
+
static void LCP_endSendCycle();
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Start of 2-byte (16-bit) data reception cycle via Link Cable
|
|
255
|
+
* Reset bit 5 in LCP_Data to 0 (ready for reading)
|
|
256
|
+
*/
|
|
257
|
+
static void LCP_startReceiveCycle();
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Main 2-byte (16-bit) data reception cycle via Link Cable
|
|
262
|
+
* Receives 4 bits at a time over 4 iterations through LCP_Data (lower 4 bits)
|
|
263
|
+
* Sets or resets bit 5 in LCP_Data depending on iteration, thereby
|
|
264
|
+
* confirming successful reading to the console that sent us data
|
|
265
|
+
* Waits for confirmation in bit 6 of LCP_Data from other console that data can be read
|
|
266
|
+
*
|
|
267
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
268
|
+
* 0x5 - failed to receive confirmation that data can be read on 1st iteration
|
|
269
|
+
* 0x6 - failed to receive confirmation that data can be read on 2nd iteration
|
|
270
|
+
* 0x7 - failed to receive confirmation that data can be read on 3rd iteration
|
|
271
|
+
* 0x8 - failed to receive confirmation that data can be read on 4th iteration
|
|
272
|
+
*
|
|
273
|
+
* return - 2 bytes of data (16 bits) received from other SEGA "aaaayyyybbbbxxxx"
|
|
274
|
+
* if no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
275
|
+
*/
|
|
276
|
+
static u16 LCP_Receive();
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* End of 2-byte (16-bit) data reading cycle via Link Cable
|
|
281
|
+
* Wait for confirmation that the other console understood the end of data reception from our console -
|
|
282
|
+
* until bit 6 in LCP_Data becomes 0 or timeout occurs, and throw error 0x9 if not received.
|
|
283
|
+
* Set bit 5 in LCP_Data to 1 - received confirmation from the other SEGA that it successfully transmitted everything.
|
|
284
|
+
*
|
|
285
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
286
|
+
* 0x9 - failed to receive confirmation that data was received by the other SEGA
|
|
287
|
+
*
|
|
288
|
+
* If no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
289
|
+
*/
|
|
290
|
+
static void LCP_endReceiveCycle();
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* End of data transmission and reception cycle via Link Cable for SEGA master console
|
|
295
|
+
* Set bit 5 in LCP_Ctrl to 1, others to 0, which means we no longer transmit data in bits 0-3
|
|
296
|
+
* Set bit 5 in LCP_Data to 1 for our master console, on the other console (slave) bit 6 will also become 1
|
|
297
|
+
* Enable processing of all interrupts
|
|
298
|
+
*/
|
|
299
|
+
static void LCP_masterCycleEnd();
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Data reception and then transmission cycle via Link Cable for SEGA slave console
|
|
304
|
+
* This is an EX-INT external interrupt handler - External interrupt in SEGA documentation
|
|
305
|
+
* It MUST NOT be called directly from game code!
|
|
306
|
+
*
|
|
307
|
+
* This function will be set as EX-INT external interrupt handler when LCP_open() is called from YOUR game code
|
|
308
|
+
* and will be disabled as external interrupt handler when LCP_close() is called from YOUR game code
|
|
309
|
+
*
|
|
310
|
+
* Function call always occurs asynchronously, interrupting your game code execution at random, unpredictable time for main game code!
|
|
311
|
+
*
|
|
312
|
+
* At the very beginning, it disables all interrupt processing and resets LCP_timeOut and LCP_error to 0
|
|
313
|
+
*
|
|
314
|
+
* Error codes (error code = LCP_error & 0x0F00):
|
|
315
|
+
* 0x100 - error calling LCP_slaveCycle() - second console port not open for data exchange
|
|
316
|
+
* 0x200 - error calling LCP_startReceiveCycle() - start of data reception from master console
|
|
317
|
+
* 0x300 - error calling size = LCP_Receive() - receiving size of transmitted data from master console
|
|
318
|
+
* 0x400 - error calling data = LCP_Receive() - receiving next 2 bytes of packet data from master console
|
|
319
|
+
* 0x500 - error calling checksum = LCP_Receive() - receiving checksum from master console
|
|
320
|
+
* 0x600 - error calling LCP_endReceiveCycle() - end of data reception from master console
|
|
321
|
+
* 0x700 - error calling LCP_startSendCycle() - start of data transmission from slave console
|
|
322
|
+
* 0x800 - error calling LCP_send(checksum) - transmitting checksum from slave console
|
|
323
|
+
* 0x900 - error calling LCP_send(size) - transmitting size of packet to be sent from slave console
|
|
324
|
+
* 0xA00 - error calling LCP_send(data) - transmitting next 2 bytes of packet data from slave console
|
|
325
|
+
* 0xB00 - error calling LCP_send(checksum) - transmitting checksum from slave console
|
|
326
|
+
* 0xC00 - error calling LCP_endSendCycle() - end of data transmission from slave console
|
|
327
|
+
* 0xD00 - error calling LCP_startReceiveCycle() - start of data reception from master console
|
|
328
|
+
* 0xE00 - error calling data = LCP_Receive() - receiving checksum from master console
|
|
329
|
+
*
|
|
330
|
+
* Error codes (error code = LCP_error & 0x00F0):
|
|
331
|
+
* 0x80 - checksum calculated by slave console <> checksum received from master console
|
|
332
|
+
* 0xC0 - checksum calculated by slave console <> checksum received from master console
|
|
333
|
+
*/
|
|
334
|
+
static void LCP_slaveCycle();
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* End of data reception and then transmission cycle via Link Cable for SEGA slave console
|
|
339
|
+
* Switches console's 2nd port to data reception mode via Link Cable, on all pins except pin 5
|
|
340
|
+
* Set bit 5 in LCP_Ctrl to 1, others to 0, which means we no longer transmit data in bits 0-3
|
|
341
|
+
* Set bit 5 in LCP_Data to 1 for our slave console, on the other console (master) bit 6 will also become 1
|
|
342
|
+
* Re-enables processing of all interrupts
|
|
343
|
+
*
|
|
344
|
+
* Error codes (error code = LCP_error & 0x0F00):
|
|
345
|
+
* 0xF00 - error calling LCP_slaveCycleEnd() - end of data reception cycle from slave console
|
|
346
|
+
*/
|
|
347
|
+
static void LCP_slaveCycleEnd();
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Reset start and end indices of data in packet for transmission via Link Cable (LCP_sendPacket array)
|
|
352
|
+
*/
|
|
353
|
+
void LCP_clearSendHeadAndTail();
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Reset start and end indices of data in packet for reception via Link Cable (LCP_ReceivePacket array)
|
|
358
|
+
*/
|
|
359
|
+
void LCP_clearReceiveHeadAndTail();
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Library functions implementation
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Opening console's 2nd port for data exchange via Link Cable
|
|
368
|
+
* upon external interrupt occurrence - External interrupt (EX-INT)
|
|
369
|
+
* interrupt mask level 2 for 68000 processor
|
|
370
|
+
* setting callback function called upon EX-INT interrupt occurrence
|
|
371
|
+
*/
|
|
372
|
+
void LCP_open() {
|
|
373
|
+
|
|
374
|
+
// capture Z80 coprocessor bus
|
|
375
|
+
//
|
|
376
|
+
// Write word $0100 to address $A11100
|
|
377
|
+
// and wait in loop until bit D8 becomes equal to 0
|
|
378
|
+
bool busTaken = Z80_getAndRequestBus(TRUE);
|
|
379
|
+
|
|
380
|
+
// Disable interrupts via SR - Status Register, since interrupt mask level 7 will be set for 68000 processor
|
|
381
|
+
//
|
|
382
|
+
// Status Register looks like this:
|
|
383
|
+
// Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
|
|
384
|
+
// ---------------------------------------------------
|
|
385
|
+
// | T| -| S| -| -| I2,I1,I0 | -| -| -| X| N| Z| V| C|
|
|
386
|
+
// ---------------------------------------------------
|
|
387
|
+
// I2, I1, I0 - interrupt masks, define minimum level of serviced interrupt requests
|
|
388
|
+
//
|
|
389
|
+
// Total of 3 interrupt types: EX-INT, H-INT, V-INT
|
|
390
|
+
//
|
|
391
|
+
// | I2 | I1 | I0 |
|
|
392
|
+
//
|
|
393
|
+
// level 0 | 0 0 0 | ---------> lowest priority
|
|
394
|
+
// level 1 | 0 0 1 |
|
|
395
|
+
// level 2 | 0 1 0 | External interrupt (EX-INT)
|
|
396
|
+
// level 3 | 0 1 1 |
|
|
397
|
+
// level 4 | 1 0 0 | Horizontal interrupt (H-INT)
|
|
398
|
+
// level 5 | 1 0 1 |
|
|
399
|
+
// level 6 | 1 1 0 | Vertical interrupt (V-INT)
|
|
400
|
+
// level 7 | 1 1 1 | ---------> highest priority
|
|
401
|
+
//
|
|
402
|
+
// When setting 7 = i.e. binary 111, I2 = 1, I1 = 1, I0 = 1
|
|
403
|
+
// all interrupts are ignored, since their levels are all lower
|
|
404
|
+
SYS_setInterruptMaskLevel(7);
|
|
405
|
+
|
|
406
|
+
// Set function that will be called upon occurrence of
|
|
407
|
+
// external interrupt EX-INT - External interrupt
|
|
408
|
+
// i.e. game code execution will be interrupted upon EX-INT interrupt occurrence, register state will be saved
|
|
409
|
+
// then the function passed to SYS_setExtIntCallback - LCP_slaveCycle() will be called, upon completion register state is restored and
|
|
410
|
+
// game code will continue from where it was interrupted
|
|
411
|
+
SYS_setExtIntCallback(LCP_slaveCycle);
|
|
412
|
+
|
|
413
|
+
// Enable external interrupt (interrupt mask level 2 for 68000 processor)
|
|
414
|
+
//
|
|
415
|
+
// Register 11 looks like this:
|
|
416
|
+
// Bit 7 6 5 4 3 2 1 0
|
|
417
|
+
// | - | - | - | - | IE2 | VSCR | HSCR | LSCR |
|
|
418
|
+
//
|
|
419
|
+
// Setting register 11 to 8 or in binary to 00001000
|
|
420
|
+
// i.e. flags will take these values:
|
|
421
|
+
// VSCR = 0 - vertical scroll mode = FULL SCROLL
|
|
422
|
+
// HSCR = 0, LSCR = 0 - horizontal scroll mode = FULL SCROLL
|
|
423
|
+
// IE2 = 1 - enables external interrupt (level 2 for 68000 External interrupt - EX-INT)
|
|
424
|
+
VDP_setReg(11, 8);
|
|
425
|
+
|
|
426
|
+
// ready for data exchange via console's 2nd port upon EX-INT interrupt occurrence
|
|
427
|
+
// first reading data from port, then writing to port in external interrupt handler LCP_slaveCycle()
|
|
428
|
+
// Interrupt on SYN line signal enabled, bit 7 = 1.
|
|
429
|
+
// data line PC5 in output mode (transmission), bit 5 = 1.
|
|
430
|
+
// data lines PC6, PC4, PC3, PC2, PC1, PC0 in input mode (reception). Corresponding bits = 0
|
|
431
|
+
// enable pins 0-3 of 2nd controller port for data reception
|
|
432
|
+
// pin 5 for signal that data is received by our console (on other console this will be bit 6 of LCP_Data)
|
|
433
|
+
// pin 6 signal that data was sent by other console (other console should change bit 5 of its LCP_Data)
|
|
434
|
+
LCP_Ctrl = LCP_BIT7_AND_BIT5;
|
|
435
|
+
|
|
436
|
+
// Set bit 5 to 1 in LCP_Data (on other console bit 6 will become 1 in LCP_Data)
|
|
437
|
+
LCP_Data |= LCP_BIT5;
|
|
438
|
+
|
|
439
|
+
// flag that port is open and data exchange after EX-INT interrupt occurrence is allowed
|
|
440
|
+
LCP_portOpen = 1;
|
|
441
|
+
|
|
442
|
+
// Enable all interrupts via SR - Status Register
|
|
443
|
+
//
|
|
444
|
+
// set level 1 for 68000 processor, which means all interrupts will be processed
|
|
445
|
+
// since their mask is higher than 1
|
|
446
|
+
SYS_setInterruptMaskLevel(1);
|
|
447
|
+
|
|
448
|
+
if (!busTaken) {
|
|
449
|
+
// release Z80 bus
|
|
450
|
+
// write word $0000 to address $A11100
|
|
451
|
+
Z80_releaseBus();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Initialization of console's 2nd port for data exchange via Link Cable
|
|
458
|
+
* for direct data writing to port and then reading data from port
|
|
459
|
+
* EX-INT interrupts are disabled for this console
|
|
460
|
+
* reset global variables
|
|
461
|
+
*/
|
|
462
|
+
void LCP_init() {
|
|
463
|
+
// reset LCP_sendHead and LCP_sendTail to zero
|
|
464
|
+
LCP_clearSendHeadAndTail();
|
|
465
|
+
|
|
466
|
+
// reset LCP_ReceiveHead and LCP_ReceiveTail to zero
|
|
467
|
+
LCP_clearReceiveHeadAndTail();
|
|
468
|
+
|
|
469
|
+
// reset errors
|
|
470
|
+
LCP_error = 0;
|
|
471
|
+
|
|
472
|
+
// capture Z80 coprocessor bus
|
|
473
|
+
bool busTaken = Z80_getAndRequestBus(TRUE);
|
|
474
|
+
|
|
475
|
+
// flag that port is initialized and data exchange starts with writing to port without waiting for external interrupt occurrence
|
|
476
|
+
// i.e. we trigger external interrupt on other console and after write cycle to port we start reading data from port
|
|
477
|
+
LCP_portOpen = 0;
|
|
478
|
+
|
|
479
|
+
// Disable all interrupts except V-INT via SR - Status Register, since interrupt mask level 5 will be set for 68000 processor
|
|
480
|
+
//
|
|
481
|
+
// Status Register looks like this:
|
|
482
|
+
// Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
|
|
483
|
+
// ---------------------------------------------------
|
|
484
|
+
// | T| -| S| -| -| I2,I1,I0 | -| -| -| X| N| Z| V| C|
|
|
485
|
+
// ---------------------------------------------------
|
|
486
|
+
// I2, I1, I0 - interrupt masks, define minimum level of serviced interrupt requests
|
|
487
|
+
//
|
|
488
|
+
// Total of 3 interrupt types: EX-INT, H-INT, V-INT
|
|
489
|
+
//
|
|
490
|
+
// | I2 | I1 | I0 |
|
|
491
|
+
//
|
|
492
|
+
// level 0 | 0 0 0 | ---------> lowest priority
|
|
493
|
+
// level 1 | 0 0 1 |
|
|
494
|
+
// level 2 | 0 1 0 | External interrupt (EX-INT)
|
|
495
|
+
// level 3 | 0 1 1 |
|
|
496
|
+
// level 4 | 1 0 0 | Horizontal interrupt (H-INT)
|
|
497
|
+
// level 5 | 1 0 1 |
|
|
498
|
+
// level 6 | 1 1 0 | Vertical interrupt (V-INT)
|
|
499
|
+
// level 7 | 1 1 1 | ---------> highest priority
|
|
500
|
+
SYS_setInterruptMaskLevel(5);
|
|
501
|
+
|
|
502
|
+
// Disable external interrupt (interrupt mask level 2 for 68000 processor)
|
|
503
|
+
//
|
|
504
|
+
// Setting register 11 to 0, i.e:
|
|
505
|
+
// VSCR = 0 - vertical scroll mode = FULL SCROLL
|
|
506
|
+
// HSCR = 0, LSCR = 0 - horizontal scroll mode = FULL SCROLL
|
|
507
|
+
// IE2 = 0 - disables external interrupt (level 2 for 68000 processor External interrupt - EX-INT)
|
|
508
|
+
VDP_setReg(11, 0);
|
|
509
|
+
|
|
510
|
+
// ready for data exchange via console's 2nd port not upon interrupt occurrence, but
|
|
511
|
+
// through direct writing to port and then reading from it. For this, you need to use LCP_masterCycle() in your game code
|
|
512
|
+
//
|
|
513
|
+
// Interrupt on SYN line signal disabled, bit 7 = 0.
|
|
514
|
+
// data line PC5 in output mode (transmission), bit 5 = 1.
|
|
515
|
+
// data lines PC6, PC4, PC3, PC2, PC1, PC0 in input mode (reception). Corresponding bits = 0
|
|
516
|
+
// enable pins 0-3 of 2nd controller port for data reception
|
|
517
|
+
// pin 5 for signaling events to other console (on other console bit 6 of LCP_Data will equal what we set in our 5th bit)
|
|
518
|
+
// pin 6 signal from other console about events (other console should change bit 5 of its LCP_Data so that our 6th bit changes)
|
|
519
|
+
LCP_Ctrl = LCP_BIT5;
|
|
520
|
+
|
|
521
|
+
// Set bit 5 to 1 in LCP_Data (on other console bit 6 will become 1 in LCP_Data)
|
|
522
|
+
LCP_Data |= LCP_BIT5;
|
|
523
|
+
|
|
524
|
+
if (!busTaken) {
|
|
525
|
+
// release Z80 bus
|
|
526
|
+
// write word $0000 to address $A11100
|
|
527
|
+
Z80_releaseBus();
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Closing console port for data exchange via Link Cable
|
|
534
|
+
* disable external interrupt handler - External interrupt (EX-INT)
|
|
535
|
+
* interrupt mask level 2 for 68000 processor
|
|
536
|
+
*/
|
|
537
|
+
void LCP_close() {
|
|
538
|
+
// disable EX-INT external interrupt handler - External interrupt in SEGA documentation
|
|
539
|
+
SYS_setExtIntCallback(NULL);
|
|
540
|
+
// reset LCP state
|
|
541
|
+
LCP_init();
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Reset start and end indices of data in packet for transmission via Link Cable (LCP_sendPacket array)
|
|
547
|
+
*/
|
|
548
|
+
void LCP_clearSendHeadAndTail() {
|
|
549
|
+
LCP_sendHead = 0;
|
|
550
|
+
LCP_sendTail = 0;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Reset start and end indices of data in packet for reception via Link Cable (LCP_ReceivePacket array)
|
|
556
|
+
*/
|
|
557
|
+
void LCP_clearReceiveHeadAndTail() {
|
|
558
|
+
LCP_ReceiveHead = 0;
|
|
559
|
+
LCP_ReceiveTail = 0;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Start of 2-byte (16-bit) data transmission cycle via Link Cable
|
|
565
|
+
* Reset bit 5 in LCP_Data to 0 - data not ready for reading by other console
|
|
566
|
+
* Set LCP_Ctrl = 00101111 to enable on controller's 2nd port:
|
|
567
|
+
* pins 0-3 for data transmission, and pin 5 for signal that data can be read
|
|
568
|
+
* by other console. As soon as we set it to 1, we expect pin 6 to be 0
|
|
569
|
+
* at function call time (if it's 1, we'll wait for 0 until timeout occurs and throw error 0xA if not received)
|
|
570
|
+
*
|
|
571
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
572
|
+
* 0xA - data transmission preparation error (failed to get 0 on pin 6 of 2nd controller)
|
|
573
|
+
*
|
|
574
|
+
* If no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
575
|
+
*/
|
|
576
|
+
static void LCP_startSendCycle() {
|
|
577
|
+
|
|
578
|
+
// Reset bit 5 - data not ready for reading by other console yet
|
|
579
|
+
LCP_Data &= ~(1 << 5);
|
|
580
|
+
// LCP_Data = "r10rrrrr" - where r is any value and doesn't matter currently
|
|
581
|
+
|
|
582
|
+
// set timeout for waiting for 0 in bit 6 of LCP_Data
|
|
583
|
+
u16 timeout = LCP_TIME_OUT;
|
|
584
|
+
|
|
585
|
+
do {
|
|
586
|
+
timeout--;
|
|
587
|
+
if (timeout == 0) {
|
|
588
|
+
// failed to get 0 on pin 6 of 2nd controller
|
|
589
|
+
LCP_timeOut++;
|
|
590
|
+
// data transmission preparation error
|
|
591
|
+
LCP_error = 0xA;
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
} while (LCP_Data & LCP_BIT6); // wait until bit 6 becomes 0 in LCP_Data
|
|
595
|
+
|
|
596
|
+
// LCP_Data = "r00rrrrr" - where r is any value and doesn't matter currently
|
|
597
|
+
|
|
598
|
+
// start data write cycle to 2nd port, write '00101111' to LCP_Ctrl
|
|
599
|
+
// interrupt on SYN line signal disabled, bit 7 = 0.
|
|
600
|
+
// data lines PC5, PC3, PC2, PC1, PC0 in output mode (transmission), bits 5, 3, 2, 1, 0 = 1.
|
|
601
|
+
// data lines PC6, PC4 in input mode (reception). Corresponding bits = 0
|
|
602
|
+
// enable pins 0-3 of 2nd controller port for data transmission
|
|
603
|
+
// pin 5 for signal that data can be read by other console (on other console this will be bit 6 of LCP_Data)
|
|
604
|
+
// pin 6 signal that data was read by other console (other console should change bit 5 of its LCP_Data)
|
|
605
|
+
LCP_Ctrl = LCP_BIT_5_3_2_1_0;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Main 2-byte (16-bit) data transmission cycle via Link Cable
|
|
611
|
+
* Transmission is done through LCP_Data - shared memory area of both consoles
|
|
612
|
+
* 4 bits at a time, i.e. in 4 iterations since 2 bytes = 16 bits
|
|
613
|
+
* Fills the lower 4 data bits in LCP_Data that we're sending
|
|
614
|
+
* Sets or resets bit 5 depending on iteration in LCP_Data
|
|
615
|
+
* Waits for data reception confirmation from other console in bit 6 of LCP_Data
|
|
616
|
+
* If confirmation is not received, saves error in LCP_error
|
|
617
|
+
*
|
|
618
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
619
|
+
* 0x1 - failed to receive confirmation on 1st iteration
|
|
620
|
+
* 0x2 - failed to receive confirmation on 2nd iteration
|
|
621
|
+
* 0x3 - failed to receive confirmation on 3rd iteration
|
|
622
|
+
* 0x4 - failed to receive confirmation on 4th iteration
|
|
623
|
+
*
|
|
624
|
+
* data - 2 bytes of data (16 bits) to transmit
|
|
625
|
+
* Let's assume initial data = "aaaayyyybbbbxxxx" - split 2 bytes (16 bits) into 4-bit chunks:
|
|
626
|
+
* first transmit aaaa, then yyyy, then bbbb, and in 4th iteration xxxx
|
|
627
|
+
*
|
|
628
|
+
* At function call time LCP_Data = "r00rrrrr" - where r is any value and doesn't matter currently
|
|
629
|
+
* LCP_startSendCycle function must have completed successfully first, or another LCP_send must complete successfully
|
|
630
|
+
*
|
|
631
|
+
* If no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
632
|
+
*/
|
|
633
|
+
static void LCP_send(u16 data) {
|
|
634
|
+
// timeout
|
|
635
|
+
u16 timeout;
|
|
636
|
+
|
|
637
|
+
// temporary variable for manipulations with LCP_Data content
|
|
638
|
+
u8 tmp = 0;
|
|
639
|
+
|
|
640
|
+
// i - data transmission iteration (total of four iterations)
|
|
641
|
+
u8 i = 1;
|
|
642
|
+
do {
|
|
643
|
+
// cyclic shift left by 4 (now lower 4 bits contain data we want to transmit)
|
|
644
|
+
// data = "aaaayyyybbbbxxxx" was for i = 1, for i = 3 was data = "bbbbxxxxaaaayyyy"
|
|
645
|
+
data = (data << 4) | (data >> 12);
|
|
646
|
+
// data = "yyyybbbbxxxxaaaa" became for i = 1, for i = 3 became data = "xxxxaaaayyyybbbb"
|
|
647
|
+
// we'll transmit aaaa or bbbb depending on iteration 1 or 3
|
|
648
|
+
tmp = LCP_Data;
|
|
649
|
+
// write 4 bits we want to transmit into lower 4 bits of LCP_Data
|
|
650
|
+
// keep upper 4 bits from LCP_Data in place, i.e. (LCP_Data & 11110000)
|
|
651
|
+
// and lower 4 bits of LCP_Data will be lower 4 bits from data, i.e. (data & 00001111)
|
|
652
|
+
// LCP_Data = (LCP_Data & 11110000) | (data & 00001111)
|
|
653
|
+
tmp = (tmp & LCP_HI_BITS) | (data & LCP_LO_BITS);
|
|
654
|
+
LCP_Data = tmp;
|
|
655
|
+
// after this operation:
|
|
656
|
+
// LCP_Data = "r00raaaa" for i = 1, LCP_Data = "r00rbbbb" for i = 3
|
|
657
|
+
|
|
658
|
+
// first and third iteration of data transmission to other SEGA
|
|
659
|
+
// set bit 5 in LCP_Data to 1 (signal that data can be read by other SEGA)
|
|
660
|
+
LCP_Data |= (1 << 5);
|
|
661
|
+
// LCP_Data = "r01raaaa" for i = 1, LCP_Data = "r01rbbbb" for i = 3
|
|
662
|
+
// On other SEGA, bit 6 in LCP_Data will change to 1, because pin 5 of our 2nd controller port
|
|
663
|
+
// is connected to pin 6 of other SEGA's 2nd controller
|
|
664
|
+
|
|
665
|
+
// set timeout
|
|
666
|
+
timeout = LCP_TIME_OUT;
|
|
667
|
+
|
|
668
|
+
// Wait for data to be read by other SEGA
|
|
669
|
+
do {
|
|
670
|
+
// decrease timeout value by 1
|
|
671
|
+
timeout--;
|
|
672
|
+
if (timeout == 0) {
|
|
673
|
+
// failed to receive signal from other SEGA that data was read
|
|
674
|
+
// Increase LCP_timeOut by 1
|
|
675
|
+
LCP_timeOut++;
|
|
676
|
+
|
|
677
|
+
// write i to LCP_error, which equals 1 or 3 (iteration)
|
|
678
|
+
LCP_error = i;
|
|
679
|
+
// LCP_error == 0x1 - failed to receive confirmation on 1st iteration
|
|
680
|
+
// LCP_error == 0x3 - failed to receive confirmation on 3rd iteration
|
|
681
|
+
|
|
682
|
+
// Exit function with error, LCP_error != 0
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
// wait until bit 6 becomes 1 in LCP_Data (signal that data was read by other SEGA)
|
|
686
|
+
// Other SEGA should set bit 5 in its LCP_Data to 1, because its pin 5 of 2nd controller port
|
|
687
|
+
// is connected to pin 6 of our SEGA's 2nd controller, and when it sets bit 5 to 1, our bit 6 will also become 1
|
|
688
|
+
} while (!(LCP_Data & LCP_BIT6));
|
|
689
|
+
// data transmission iteration completed successfully,
|
|
690
|
+
// transmitted via Link Cable "aaaa" for 1st iteration or "bbbb" for 3rd iteration
|
|
691
|
+
// LCP_Data = "r11raaaa" for i = 1, LCP_Data = "r11rbbbb" for i = 3
|
|
692
|
+
|
|
693
|
+
// increase iteration number
|
|
694
|
+
i++;
|
|
695
|
+
// now i = 2 or i = 4
|
|
696
|
+
|
|
697
|
+
// cyclic shift left by 4 (now lower 4 bits contain next data we want to transmit)
|
|
698
|
+
// data = "yyyybbbbxxxxaaaa" was for i = 2, for i = 4 was data = "xxxxaaaayyyybbbb"
|
|
699
|
+
data = (data << 4) | (data >> 12);
|
|
700
|
+
// data = "bbbbxxxxaaaayyyy" became for i = 2, for i = 4 became data = "aaaayyyybbbbxxxx"
|
|
701
|
+
tmp = LCP_Data;
|
|
702
|
+
// write 4 bits we want to transmit into lower 4 bits of LCP_Data
|
|
703
|
+
// Keep upper 4 bits from LCP_Data in place, i.e. (LCP_Data & 11110000)
|
|
704
|
+
// and lower 4 bits of LCP_Data will be lower 4 bits from data, i.e. (data & 00001111)
|
|
705
|
+
// LCP_Data = (LCP_Data & 11110000) | (data & 00001111)
|
|
706
|
+
tmp = (tmp & LCP_HI_BITS) | (data & LCP_LO_BITS);
|
|
707
|
+
LCP_Data = tmp;
|
|
708
|
+
// after this operation:
|
|
709
|
+
// LCP_Data = "r11ryyyy" for i = 2, LCP_Data = "r00rxxxx" for i = 4
|
|
710
|
+
|
|
711
|
+
// second and fourth iteration of data transmission to other SEGA
|
|
712
|
+
// set bit 5 in LCP_Data to 0 (signal that data can be read by other SEGA)
|
|
713
|
+
LCP_Data &= ~(1 << 5);
|
|
714
|
+
// LCP_Data = "r10ryyyy" for i = 2, LCP_Data = "r10rxxxx" for i = 4
|
|
715
|
+
|
|
716
|
+
// set timeout again
|
|
717
|
+
timeout = LCP_TIME_OUT;
|
|
718
|
+
|
|
719
|
+
// Wait for data to be read by other SEGA
|
|
720
|
+
do {
|
|
721
|
+
// decrease timeout value by 1
|
|
722
|
+
timeout--;
|
|
723
|
+
if (timeout == 0) {
|
|
724
|
+
// failed to receive signal from other SEGA that data was read
|
|
725
|
+
// Increase LCP_timeOut by 1
|
|
726
|
+
LCP_timeOut++;
|
|
727
|
+
|
|
728
|
+
// write i to LCP_error, which equals 2 or 4 (iteration)
|
|
729
|
+
LCP_error = i;
|
|
730
|
+
// LCP_error == 0x2 - failed to receive confirmation on 2nd iteration
|
|
731
|
+
// LCP_error == 0x4 - failed to receive confirmation on 4th iteration
|
|
732
|
+
|
|
733
|
+
// Exit function with error, LCP_error != 0
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
// wait until bit 6 becomes 0 in LCP_Data (signal that data was read by other SEGA)
|
|
737
|
+
} while (LCP_Data & LCP_BIT6);
|
|
738
|
+
// data transmission iteration completed successfully,
|
|
739
|
+
// transmitted via Link Cable "yyyy" for 2nd iteration or "xxxx" for 4th iteration
|
|
740
|
+
// LCP_Data = "r00ryyyy" for i = 2, LCP_Data = "r00rxxxx" for i = 4
|
|
741
|
+
|
|
742
|
+
// increase iteration number
|
|
743
|
+
i++;
|
|
744
|
+
// now i = 3 for 2nd iteration or i = 5 for 4th iteration
|
|
745
|
+
|
|
746
|
+
// continue until i becomes 5, meaning everything transmitted, exit (2 cycles total - 2 transmission iterations each)
|
|
747
|
+
} while (i < 5);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* End of 2-byte (16-bit) data transmission cycle via Link Cable
|
|
753
|
+
* Set LCP_Ctrl = 00100000 to enable on controller's 2nd port:
|
|
754
|
+
* pins 0-3 for data reception, and pin 5 for signal that our SEGA is ready to receive data.
|
|
755
|
+
* Reset bit 5 in LCP_Data to 0, wait for confirmation that other console is ready to send data -
|
|
756
|
+
* until bit 6 in LCP_Data becomes 1 or timeout occurs, and throw error 0xB if not received.
|
|
757
|
+
*
|
|
758
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
759
|
+
* 0xB - data transmission cycle end error (failed to get 1 in bit 6 of LCP_Data)
|
|
760
|
+
*
|
|
761
|
+
* If no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
762
|
+
*/
|
|
763
|
+
static void LCP_endSendCycle() {
|
|
764
|
+
// set timeout
|
|
765
|
+
u16 timeout = LCP_TIME_OUT;
|
|
766
|
+
|
|
767
|
+
// switch port to data reception mode
|
|
768
|
+
// Interrupt on SYN line signal disabled, bit 7 = 0.
|
|
769
|
+
// data line PC5 in output mode (transmission), bit 5 = 1.
|
|
770
|
+
// data lines PC6, PC4, PC3, PC2, PC1, PC0 in input mode (reception). Corresponding bits = 0
|
|
771
|
+
// enable pins 0-3 of 2nd controller port for data reception
|
|
772
|
+
// pin 5 for signaling events to other console (on other console bit 6 of LCP_Data will equal what we set in our 5th bit)
|
|
773
|
+
// pin 6 signal from other console about events (other console should change bit 5 of its LCP_Data so that our 6th bit changes)
|
|
774
|
+
LCP_Ctrl = LCP_BIT5;
|
|
775
|
+
|
|
776
|
+
// Reset bit 5 to 0 in LCP_Data
|
|
777
|
+
LCP_Data &= ~(1 << 5);
|
|
778
|
+
// LCP_Data = "r00rrrrr" - where r is any value and doesn't matter currently
|
|
779
|
+
|
|
780
|
+
// Wait for bit 6 in LCP_Data to become 1, other SEGA is ready to send data
|
|
781
|
+
// and our console is ready to receive
|
|
782
|
+
do {
|
|
783
|
+
// decrease timeout value by 1
|
|
784
|
+
timeout--;
|
|
785
|
+
if (timeout == 0) {
|
|
786
|
+
// failed to get 1 in bit 6 of LCP_Data, meaning second SEGA is not ready to send data
|
|
787
|
+
LCP_timeOut++;
|
|
788
|
+
// 0xB - data transmission cycle end error
|
|
789
|
+
LCP_error = 0xB;
|
|
790
|
+
// Exit function with error, LCP_error != 0
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// wait until bit 6 becomes 1 in LCP_Data (signal that other SEGA is ready to send data to our SEGA)
|
|
795
|
+
} while (!(LCP_Data & LCP_BIT6));
|
|
796
|
+
|
|
797
|
+
// LCP_Data = "r10rrrrr" - where r is any value and doesn't matter currently
|
|
798
|
+
|
|
799
|
+
// It is assumed that after executing this function, if we want to read data via Link Cable
|
|
800
|
+
// we should call LCP_startReceiveCycle()
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Start of 2-byte (16-bit) data reception cycle via Link Cable
|
|
806
|
+
* Reset bit 5 in LCP_Data to 0 (ready for reading)
|
|
807
|
+
*/
|
|
808
|
+
static void LCP_startReceiveCycle() {
|
|
809
|
+
// Reset bit 5 in LCP_Data (ready for reading)
|
|
810
|
+
LCP_Data &= ~(1 << 5);
|
|
811
|
+
// LCP_Data = "r00rrrrr" - where r is any value and doesn't matter currently
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Main 2-byte (16-bit) data reception cycle via Link Cable
|
|
817
|
+
* Receives 4 bits at a time over 4 iterations through LCP_Data (lower 4 bits)
|
|
818
|
+
* Sets or resets bit 5 in LCP_Data depending on iteration, thereby
|
|
819
|
+
* confirming successful reading to the console that sent us data
|
|
820
|
+
* Waits for confirmation in bit 6 of LCP_Data from other console that data can be read
|
|
821
|
+
*
|
|
822
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
823
|
+
* 0x5 - failed to receive confirmation that data can be read on 1st iteration
|
|
824
|
+
* 0x6 - failed to receive confirmation that data can be read on 2nd iteration
|
|
825
|
+
* 0x7 - failed to receive confirmation that data can be read on 3rd iteration
|
|
826
|
+
* 0x8 - failed to receive confirmation that data can be read on 4th iteration
|
|
827
|
+
*
|
|
828
|
+
* return - 2 bytes of data (16 bits) received from other SEGA "aaaayyyybbbbxxxx"
|
|
829
|
+
* if no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
830
|
+
*/
|
|
831
|
+
static u16 LCP_Receive() {
|
|
832
|
+
// here will be data read from other SEGA, 16-bit variable (2 bytes)
|
|
833
|
+
u16 data = 0;
|
|
834
|
+
// data = "0000000000000000"
|
|
835
|
+
|
|
836
|
+
// temporary variable for manipulations with LCP_Data content
|
|
837
|
+
u8 tmp = 0;
|
|
838
|
+
|
|
839
|
+
// timeout
|
|
840
|
+
u16 timeout;
|
|
841
|
+
|
|
842
|
+
// data transmission iteration (total of four iterations)
|
|
843
|
+
// starting from 5 so reception errors differ from transmission errors
|
|
844
|
+
// 5 - 1st reception iteration, 6 - 2nd, 7 - 3rd, 8 - 4th reception iteration
|
|
845
|
+
u8 i = 5;
|
|
846
|
+
|
|
847
|
+
do {
|
|
848
|
+
// set timeout
|
|
849
|
+
timeout = LCP_TIME_OUT;
|
|
850
|
+
|
|
851
|
+
// Wait for bit 6 in LCP_Data to become 1, other SEGA has sent data
|
|
852
|
+
do {
|
|
853
|
+
// decrease timeout value by 1
|
|
854
|
+
timeout--;
|
|
855
|
+
if (timeout == 0) {
|
|
856
|
+
// failed to receive signal from other SEGA that data was sent to us
|
|
857
|
+
// Increase LCP_timeOut
|
|
858
|
+
LCP_timeOut++;
|
|
859
|
+
|
|
860
|
+
// write i to LCP_error, which equals 5 or 7 (1st or 3rd iteration)
|
|
861
|
+
LCP_error = i;
|
|
862
|
+
// LCP_error == 0x5 - failed to receive confirmation that data can be read on 1st iteration
|
|
863
|
+
// LCP_error == 0x7 - failed to receive confirmation that data can be read on 3rd iteration
|
|
864
|
+
|
|
865
|
+
// If timeout reached 0, exit loop and return current data
|
|
866
|
+
return data;
|
|
867
|
+
// data = "0000000000000000" for 1st iteration (i = 5)
|
|
868
|
+
// or data = "00000000aaaayyyy" for 3rd iteration (i = 7)
|
|
869
|
+
}
|
|
870
|
+
// loop continues until bit 6 becomes 1 - signal from other SEGA that data can be read by us
|
|
871
|
+
// Other SEGA should set bit 5 in its LCP_Data to 1, because its pin 5 of 2nd controller port
|
|
872
|
+
// is connected to pin 6 of our SEGA's 2nd controller, and when it sets bit 5 to 1, our bit 6 will also become 1
|
|
873
|
+
} while (!(LCP_Data & LCP_BIT6));
|
|
874
|
+
// data reception iteration completed successfully,
|
|
875
|
+
// received via Link Cable "aaaa" for 1st iteration or "bbbb" for 3rd iteration
|
|
876
|
+
// LCP_Data = "r10raaaa" for i = 5, LCP_Data = "r10rbbbb" for i = 7
|
|
877
|
+
// temporary variable for manipulations with LCP_Data content
|
|
878
|
+
tmp = LCP_Data;
|
|
879
|
+
// now we need to save received 4 bits to data
|
|
880
|
+
// for this we shift all bits in data left by 4 bits (data << 4)
|
|
881
|
+
// for 1st iteration this doesn't matter since it's 0, but for 3rd (i = 7) we transform "00000000aaaayyyy" into "0000aaaayyyy0000"
|
|
882
|
+
// now take only lower 4 bits from LCP_Data (LCP_Data & 00001111) and combine with result from first expression
|
|
883
|
+
data = (data << 4) | (tmp & LCP_LO_BITS);
|
|
884
|
+
// data = "000000000000aaaa" for 1st iteration (i == 5), "0000aaaayyyybbbb" for 3rd iteration (i == 7)
|
|
885
|
+
|
|
886
|
+
// 1st or 2nd iteration of data reception from other SEGA completed, data saved to data
|
|
887
|
+
// set bit 5 in LCP_Data to 1 (read data, notify other SEGA about this)
|
|
888
|
+
LCP_Data |= (1 << 5);
|
|
889
|
+
// LCP_Data = "r11raaaa" for 1st iteration (i == 5) or LCP_Data = "r11rbbbb" for 3rd iteration (i == 7)
|
|
890
|
+
|
|
891
|
+
// increase iteration number
|
|
892
|
+
i++;
|
|
893
|
+
// now i = 6 for 2nd iteration or i = 8 for 4th
|
|
894
|
+
|
|
895
|
+
// Set timeout again
|
|
896
|
+
timeout = LCP_TIME_OUT;
|
|
897
|
+
|
|
898
|
+
// Wait for bit 6 in LCP_Data to become 0, other SEGA has sent data
|
|
899
|
+
do {
|
|
900
|
+
// decrease timeout value by 1
|
|
901
|
+
timeout--;
|
|
902
|
+
if (timeout == 0) {
|
|
903
|
+
// failed to receive signal from other SEGA that data was sent to us
|
|
904
|
+
// Increase LCP_timeOut
|
|
905
|
+
LCP_timeOut++;
|
|
906
|
+
|
|
907
|
+
// write i to LCP_error, which equals 6 or 8 (2nd or 4th iteration)
|
|
908
|
+
LCP_error = i;
|
|
909
|
+
// LCP_error == 0x6 - failed to receive confirmation that data can be read on 2nd iteration
|
|
910
|
+
// LCP_error == 0x8 - failed to receive confirmation that data can be read on 4th iteration
|
|
911
|
+
|
|
912
|
+
// If timeout reached 0, exit loop and return current data
|
|
913
|
+
return data;
|
|
914
|
+
// data = "000000000000aaaa" for 1st iteration (i = 6)
|
|
915
|
+
// or data = "0000aaaayyyybbbb" for 3rd iteration (i = 8)
|
|
916
|
+
}
|
|
917
|
+
// loop continues until bit 6 becomes 0 - signal from other SEGA that data can be read by us
|
|
918
|
+
// Other SEGA should set bit 5 in its LCP_Data to 0, because its pin 5 of 2nd controller port
|
|
919
|
+
// is connected to pin 6 of our SEGA's 2nd controller, and when it sets bit 5 to 0, our bit 6 will also become 0
|
|
920
|
+
} while (LCP_Data & LCP_BIT6);
|
|
921
|
+
// data reception iteration completed successfully,
|
|
922
|
+
// received via Link Cable "yyyy" for 2nd iteration or "xxxx" for 4th iteration
|
|
923
|
+
// LCP_Data = "r01ryyyy" for i = 6, LCP_Data = "r01rxxxx" for i = 8
|
|
924
|
+
tmp = LCP_Data;
|
|
925
|
+
// now we need to save received 4 bits to data
|
|
926
|
+
// for this we shift all bits in data left by 4 bits (data << 4)
|
|
927
|
+
// for 2nd iteration (i == 6) we transform "000000000000aaaa" into "00000000aaaa0000"
|
|
928
|
+
// for 4th iteration (i = 8) we transform "0000aaaayyyybbbb" into "aaaayyyybbbb0000"
|
|
929
|
+
// take only lower 4 bits from LCP_Data (LCP_Data & 00001111) and combine with result from first expression
|
|
930
|
+
data = (data << 4) | (tmp & LCP_LO_BITS);
|
|
931
|
+
// data = "00000000aaaayyyy" for 2nd iteration (i == 6), "aaaayyyybbbbxxxx" for 4th iteration (i == 8)
|
|
932
|
+
|
|
933
|
+
// 2nd or 4th iteration of data reception from other SEGA completed, data saved to data
|
|
934
|
+
// set bit 5 in LCP_Data to 0 (read data, notify other SEGA about this)
|
|
935
|
+
LCP_Data &= ~(1 << 5);
|
|
936
|
+
// LCP_Data = "r00ryyyy" for 2nd iteration (i == 6) or LCP_Data = "r00rxxxx" for 4th iteration (i == 8)
|
|
937
|
+
|
|
938
|
+
// increase iteration number
|
|
939
|
+
i++;
|
|
940
|
+
// now i = 7 for 2nd iteration or i = 9 for 4th
|
|
941
|
+
|
|
942
|
+
// continue until i becomes 9, meaning everything received, exit (2 cycles total - 2 reception iterations each)
|
|
943
|
+
} while( i < 9);
|
|
944
|
+
|
|
945
|
+
// return read 2 bytes (16 bits) via Link Cable
|
|
946
|
+
return data;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* End of 2-byte (16-bit) data reading cycle via Link Cable
|
|
952
|
+
* Wait for confirmation that the other console understood the end of data reception from our console -
|
|
953
|
+
* until bit 6 in LCP_Data becomes 0 or timeout occurs, and throw error 0x9 if not received.
|
|
954
|
+
* Set bit 5 in LCP_Data to 1 - received confirmation from the other SEGA that it successfully transmitted everything.
|
|
955
|
+
*
|
|
956
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
957
|
+
* 0x9 - failed to receive confirmation that data was received by the other SEGA
|
|
958
|
+
*
|
|
959
|
+
* If no errors occurred (LCP_error == 0 and LCP_timeOut == 0)
|
|
960
|
+
*/
|
|
961
|
+
static void LCP_endReceiveCycle() {
|
|
962
|
+
// set timeout
|
|
963
|
+
u16 timeout = LCP_TIME_OUT;
|
|
964
|
+
|
|
965
|
+
// wait for the other SEGA console to understand that we successfully read all 2 bytes of data from it
|
|
966
|
+
do {
|
|
967
|
+
// decrease timeout value by 1
|
|
968
|
+
timeout--;
|
|
969
|
+
if (timeout == 0) {
|
|
970
|
+
LCP_timeOut++;
|
|
971
|
+
// 0x9 - failed to receive confirmation that data was received by the other SEGA
|
|
972
|
+
LCP_error = 0x9;
|
|
973
|
+
// exit function with error in LCP_error and LCP_timeOut > 0
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
// loop continues until bit 6 in LCP_Data becomes 0 - signal from other SEGA that data was read
|
|
977
|
+
} while (LCP_Data & LCP_BIT6);
|
|
978
|
+
|
|
979
|
+
// after exiting the loop
|
|
980
|
+
// LCP_Data = "r00rxxxx"
|
|
981
|
+
|
|
982
|
+
// set bit 5 in LCP_Data to 1 - received confirmation from other SEGA that it successfully transmitted everything
|
|
983
|
+
// LCP_Data = "r10rxxxx"
|
|
984
|
+
LCP_Data |= (1 << 5);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Function for copying transferObject - as byte array
|
|
990
|
+
* into LCP_sendPacket for packet transmission via Link Cable
|
|
991
|
+
* first 2 bytes in packet contain type of transmitted object (cannot be 0)
|
|
992
|
+
* then packet contains object data (2 bytes each), according to object sizes table objectTypeSizes
|
|
993
|
+
* multiple objects can be transmitted at once, main thing is they fit in buffer
|
|
994
|
+
* i.e. function can be called multiple times in row, until we get
|
|
995
|
+
* errors described below
|
|
996
|
+
*
|
|
997
|
+
* Error codes (error code = LCP_error & 0x000F):
|
|
998
|
+
* 0xC - transmitted object size is negative or equal to 0
|
|
999
|
+
* 0xD - transmitted object size exceeds remaining space in packet
|
|
1000
|
+
* 0xF - packet data start index is greater than data end index
|
|
1001
|
+
*
|
|
1002
|
+
* transferObject - transmitted object as byte array via Link Cable
|
|
1003
|
+
* objectType - type of transmitted object (number equal to index in object sizes array)
|
|
1004
|
+
* objectTypeSizes - array of object sizes (defined in main code of YOUR game)
|
|
1005
|
+
*/
|
|
1006
|
+
void LCP_objectToPacketForSend(u8 *transferObject, u16 objectType , u16 *objectTypeSizes) {
|
|
1007
|
+
// size of transmitted object from object sizes array
|
|
1008
|
+
u16 objectSize = objectTypeSizes[objectType];
|
|
1009
|
+
// end index of data in transmission packet LCP_sendPacket
|
|
1010
|
+
u16 tail = LCP_sendTail;
|
|
1011
|
+
// start index of data in transmission packet LCP_sendPacket
|
|
1012
|
+
u16 head = LCP_sendHead;
|
|
1013
|
+
|
|
1014
|
+
// check that transmitted object size is greater than 0
|
|
1015
|
+
if (objectSize <= 0) {
|
|
1016
|
+
// 0xC - transmitted object size is negative or equal to 0
|
|
1017
|
+
LCP_error = 0xC;
|
|
1018
|
+
|
|
1019
|
+
// exit function with error in LCP_error
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// check that we won't exceed LCP_sendPacket array bounds when transmitting object
|
|
1024
|
+
if (objectSize > LCP_PACKET_SIZE - head) {
|
|
1025
|
+
// 0xD - transmitted object size exceeds remaining space in packet
|
|
1026
|
+
LCP_error = 0xD;
|
|
1027
|
+
|
|
1028
|
+
// exit function with error in LCP_error
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
// check that data start index is not greater than data end index in packet
|
|
1033
|
+
if (head > tail) {
|
|
1034
|
+
// 0xF - packet data start index is greater than data end index
|
|
1035
|
+
LCP_error = 0xF;
|
|
1036
|
+
LCP_clearSendHeadAndTail();
|
|
1037
|
+
// exit function with error in LCP_error
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// first 2 bytes (16 bits) of packet data will contain type of transmitted object
|
|
1042
|
+
LCP_sendPacket[tail] = objectType;
|
|
1043
|
+
|
|
1044
|
+
// need to increase packet data end index by 1
|
|
1045
|
+
tail++;
|
|
1046
|
+
|
|
1047
|
+
// copy transmitted object transferObject into data transmission packet - LCP_sendPacket, starting from index
|
|
1048
|
+
// tail with size objectSize
|
|
1049
|
+
memcpy(LCP_sendPacket + tail, transferObject, objectSize);
|
|
1050
|
+
|
|
1051
|
+
// update value of data end index in LCP_sendPacket packet
|
|
1052
|
+
LCP_sendTail = tail + objectSize;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Function extracts next object as byte array transferObject from received packet LCP_ReceivePacket
|
|
1058
|
+
* via Link Cable and returns type of this object or 0 if object couldn't be extracted from LCP_ReceivePacket
|
|
1059
|
+
* since we can transmit multiple objects at once, it's assumed possible to call this function multiple times
|
|
1060
|
+
* in row until we get 0, which means - all objects have been extracted from transmitted packet
|
|
1061
|
+
*
|
|
1062
|
+
* first 2 bytes of packet in LCP_ReceivePacket contain type of transmitted object (cannot be 0)
|
|
1063
|
+
* then packet contains object data (2 bytes each), according to object sizes table objectSizes
|
|
1064
|
+
* multiple objects can be transmitted at once, main thing is they fit in LCP_ReceivePacket array
|
|
1065
|
+
*
|
|
1066
|
+
* Error codes (error code = LCP_error & 0xF000):
|
|
1067
|
+
* 0x1000 - no object in received packet, all already extracted from packet or nothing was transmitted to us
|
|
1068
|
+
* 0x2000 - size of extracted object from read packets buffer - negative or equal to 0
|
|
1069
|
+
* 0x3000 - size of extracted object exceeds remaining data in received data packet
|
|
1070
|
+
* 0x4000 - size of extracted object exceeds remaining size of LCP_ReceivePacket array
|
|
1071
|
+
*
|
|
1072
|
+
* transferObject - next received object as byte array via Link Cable
|
|
1073
|
+
* objectSizes - array of object sizes (defined in main code of YOUR game)
|
|
1074
|
+
*
|
|
1075
|
+
* return - type of received object or 0 if couldn't extract object from received packet
|
|
1076
|
+
*/
|
|
1077
|
+
u16 LCP_getNextObjectFromReceivePacket(u8 *transferObject, u16 *objectSizes) {
|
|
1078
|
+
// current index in received packet from which we'll start reading data
|
|
1079
|
+
u16 head = LCP_ReceiveHead;
|
|
1080
|
+
// end index of data in received packet
|
|
1081
|
+
u16 tail = LCP_ReceiveTail;
|
|
1082
|
+
// object type that function will return, or 0 if no object was found in received packet
|
|
1083
|
+
u16 objectType;
|
|
1084
|
+
// object size from object sizes array according to object type
|
|
1085
|
+
u16 objectSize = 0;
|
|
1086
|
+
|
|
1087
|
+
// Check for data presence in received packet (that data start doesn't match data end)
|
|
1088
|
+
if (head >= tail) {
|
|
1089
|
+
// 0x1000 - no object in received packet, all already extracted from packet or nothing was transmitted to us
|
|
1090
|
+
LCP_error |= 0x1000;
|
|
1091
|
+
// No data, return 0 (couldn't extract any object)
|
|
1092
|
+
return 0;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// read first byte - object type
|
|
1096
|
+
// it's assumed that objectSizes is declared somewhere in code of YOUR game !!!
|
|
1097
|
+
objectType = LCP_ReceivePacket[head];
|
|
1098
|
+
|
|
1099
|
+
// since we read object type, we need to shift data start index by 1
|
|
1100
|
+
head++;
|
|
1101
|
+
|
|
1102
|
+
// get object size by its type from object sizes table
|
|
1103
|
+
objectSize = objectSizes[objectType];
|
|
1104
|
+
|
|
1105
|
+
// if object size is negative or equal to 0 - error!
|
|
1106
|
+
if (objectSize <= 0) {
|
|
1107
|
+
// 0x2000 - size of extracted object from read packets buffer - negative or equal to 0
|
|
1108
|
+
LCP_error |= 0x2000;
|
|
1109
|
+
// No data, return 0 (couldn't extract any object)
|
|
1110
|
+
return 0;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// If object size exceeds remaining data in read buffer - error!
|
|
1114
|
+
if (objectSize > tail - head) {
|
|
1115
|
+
// 0x3000 - size of extracted object exceeds remaining data in received data packet
|
|
1116
|
+
LCP_error |= 0x3000;
|
|
1117
|
+
// No data, return 0 (couldn't extract any object)
|
|
1118
|
+
return 0;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// If object size exceeds remaining size of array for data reception packet
|
|
1122
|
+
if (objectSize > LCP_PACKET_SIZE - head) {
|
|
1123
|
+
// 0x4000 - size of extracted object exceeds remaining size of LCP_ReceivePacket array
|
|
1124
|
+
LCP_error |= 0x4000;
|
|
1125
|
+
// No data, return 0 (couldn't extract any object)
|
|
1126
|
+
return 0;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// copy to byte array transferObject from received packet LCP_ReceivePacket starting from index head
|
|
1130
|
+
// objectSize bytes, i.e. entire object from LCP_ReceivePacket to transferObject
|
|
1131
|
+
memcpy(transferObject, LCP_ReceivePacket + head, objectSize);
|
|
1132
|
+
|
|
1133
|
+
// since we extracted next object from packet, move start index of non-extracted objects in packet
|
|
1134
|
+
// to head + objectSize, from where on next call of LCP_getNextObjectFromReceivePacket we'll extract
|
|
1135
|
+
// next object
|
|
1136
|
+
LCP_ReceiveHead = head + objectSize;
|
|
1137
|
+
|
|
1138
|
+
if (LCP_ReceiveHead == LCP_ReceiveTail) {
|
|
1139
|
+
// if everything was read, we can reset LCP_ReceiveHead and LCP_ReceiveTail to 0
|
|
1140
|
+
LCP_clearReceiveHeadAndTail();
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
// return type of object read into transferObject from received packet LCP_ReceivePacket
|
|
1144
|
+
return objectType;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Transmission and then reception cycle via Link Cable for SEGA master console
|
|
1150
|
+
* at the very beginning disables all interrupt processing and resets LCP_timeOut and LCP_error to 0
|
|
1151
|
+
* both in case of error and in case of successful function completion, i.e. always call LCP_masterCycleEnd() at the end
|
|
1152
|
+
* to switch console's 2nd port to correct state and enable all interrupt processing.
|
|
1153
|
+
*
|
|
1154
|
+
* Error codes (error code = LCP_error & 0x00F0):
|
|
1155
|
+
* 0x10 - error calling LCP_startSendCycle() - start of data transmission from master console
|
|
1156
|
+
* 0x20 - error calling LCP_send(size) - transmission of 2 bytes (packet size) from master console
|
|
1157
|
+
* 0x30 - error calling LCP_send(data) - transmission of 2 bytes (packet data) from master console
|
|
1158
|
+
* 0x40 - error calling LCP_send(checksum) - transmission of 2 bytes (checksum) from master console
|
|
1159
|
+
* 0x50 - error calling LCP_endSendCycle() - end of main packet transmission cycle from master to slave console
|
|
1160
|
+
* 0x60 - error calling LCP_startReceiveCycle() - start of data reception cycle from slave console to master
|
|
1161
|
+
* 0x70 - error calling data = LCP_Receive() - reception of 2 bytes (packet checksum) from slave console
|
|
1162
|
+
* 0x80 - checksum calculated by master console <> checksum received from slave console
|
|
1163
|
+
* 0x90 - error calling size = LCP_Receive() - reception of 2 bytes (packet size) from slave console
|
|
1164
|
+
* 0xA0 - error calling data = LCP_Receive() - reception of 2 bytes (packet data) from slave console
|
|
1165
|
+
* 0xB0 - error calling data = LCP_Receive() - main cycle of receiving 2 bytes (checksum) from slave console
|
|
1166
|
+
* 0xC0 - checksum calculated by master console <> checksum received from slave console
|
|
1167
|
+
* 0xD0 - error calling LCP_endReceiveCycle() - end of data reception cycle from slave console
|
|
1168
|
+
* 0xE0 - error calling LCP_startSendCycle() - start of checksum transmission from master to slave console
|
|
1169
|
+
* 0xF0 - error calling LCP_send(checksum) - transmission of checksum from master to slave
|
|
1170
|
+
*/
|
|
1171
|
+
void LCP_masterCycle() {
|
|
1172
|
+
// size of transmitted or received data
|
|
1173
|
+
s16 size;
|
|
1174
|
+
// checksum for verifying transmitted data
|
|
1175
|
+
u16 checksum;
|
|
1176
|
+
// current index of transmitted or received data
|
|
1177
|
+
u16 head;
|
|
1178
|
+
// transmitted or received 2 bytes (16 bits) via Link Cable Protocol
|
|
1179
|
+
u16 data;
|
|
1180
|
+
|
|
1181
|
+
// disable interrupt processing
|
|
1182
|
+
SYS_disableInts();
|
|
1183
|
+
|
|
1184
|
+
// Clear timeout
|
|
1185
|
+
LCP_timeOut = 0;
|
|
1186
|
+
// Clear errors
|
|
1187
|
+
LCP_error = 0;
|
|
1188
|
+
|
|
1189
|
+
// start of data transmission cycle via Link Cable from main console (master) to slave console
|
|
1190
|
+
// trigger external interrupt External interrupt (EX-INT) on slave console
|
|
1191
|
+
LCP_startSendCycle();
|
|
1192
|
+
|
|
1193
|
+
if (LCP_timeOut) {
|
|
1194
|
+
// 0x10 - error calling LCP_startSendCycle() - start of data transmission from master console
|
|
1195
|
+
LCP_error |= 0x10;
|
|
1196
|
+
LCP_masterCycleEnd();
|
|
1197
|
+
// Exit function with error, LCP_error != 0
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// calculate size of data to transmit based on end and start indices in transmission packet
|
|
1202
|
+
size = LCP_sendTail - LCP_sendHead;
|
|
1203
|
+
if (size < 0) {
|
|
1204
|
+
// if size less than 0, reset both indices and size of transmitted data
|
|
1205
|
+
LCP_clearSendHeadAndTail();
|
|
1206
|
+
size = 0;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
// send packet size to slave console via Link Cable from master console
|
|
1210
|
+
LCP_send(size);
|
|
1211
|
+
|
|
1212
|
+
if (LCP_timeOut) {
|
|
1213
|
+
// 0x20 - error calling LCP_send(size) - transmission of 2 bytes (packet size) from master console
|
|
1214
|
+
LCP_error |= 0x20;
|
|
1215
|
+
LCP_masterCycleEnd();
|
|
1216
|
+
// Exit function with error, LCP_error != 0
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
// reset checksum
|
|
1221
|
+
checksum = 0;
|
|
1222
|
+
|
|
1223
|
+
// set index in transmission buffer to start of data in LCP_sendPacket
|
|
1224
|
+
head = LCP_sendHead;
|
|
1225
|
+
|
|
1226
|
+
// transmit data if size greater than 0 (there is something to transmit)
|
|
1227
|
+
for (u16 i = 0; i < size; i++) {
|
|
1228
|
+
// extract next 2 bytes from packet data for transmission
|
|
1229
|
+
data = LCP_sendPacket[head];
|
|
1230
|
+
// increase index in transmission buffer by 1
|
|
1231
|
+
head++;
|
|
1232
|
+
// calculate checksum to verify successful data transmission
|
|
1233
|
+
checksum += data;
|
|
1234
|
+
// send next 2 bytes via Link Cable to slave console
|
|
1235
|
+
LCP_send(data);
|
|
1236
|
+
|
|
1237
|
+
if (LCP_timeOut) {
|
|
1238
|
+
// 0x30 - error calling LCP_send(data) - transmission of 2 bytes (packet data) from master console
|
|
1239
|
+
LCP_error |= 0x30;
|
|
1240
|
+
LCP_masterCycleEnd();
|
|
1241
|
+
// Exit function with error, LCP_error != 0
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// send checksum to other console to verify previously transmitted data
|
|
1247
|
+
LCP_send(checksum);
|
|
1248
|
+
|
|
1249
|
+
if (LCP_timeOut) {
|
|
1250
|
+
// 0x40 - error calling LCP_send(checksum) - transmission of 2 bytes (checksum) from master console
|
|
1251
|
+
LCP_error |= 0x40;
|
|
1252
|
+
LCP_masterCycleEnd();
|
|
1253
|
+
// Exit function with error, LCP_error != 0
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
// completion of data transmission cycle via Link Cable from master to slave console
|
|
1257
|
+
LCP_endSendCycle();
|
|
1258
|
+
|
|
1259
|
+
if (LCP_timeOut) {
|
|
1260
|
+
// 0x50 - error calling LCP_endSendCycle() - end of main packet transmission cycle from master to slave console
|
|
1261
|
+
LCP_error |= 0x50;
|
|
1262
|
+
LCP_masterCycleEnd();
|
|
1263
|
+
// Exit function with error, LCP_error != 0
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// start of data reception from slave SEGA in main cycle
|
|
1268
|
+
LCP_startReceiveCycle();
|
|
1269
|
+
|
|
1270
|
+
if (LCP_timeOut) {
|
|
1271
|
+
// 0x60 - error calling LCP_startReceiveCycle() - start of data reception cycle from slave console to master
|
|
1272
|
+
LCP_error |= 0x60;
|
|
1273
|
+
LCP_masterCycleEnd();
|
|
1274
|
+
// Exit function with error, LCP_error != 0
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// read first 2 bytes from slave console
|
|
1279
|
+
data = LCP_Receive();
|
|
1280
|
+
|
|
1281
|
+
if (LCP_timeOut) {
|
|
1282
|
+
// 0x70 - error calling data = LCP_Receive() - reception of 2 bytes (packet checksum) from slave console
|
|
1283
|
+
LCP_error |= 0x70;
|
|
1284
|
+
LCP_masterCycleEnd();
|
|
1285
|
+
// Exit function with error, LCP_error != 0
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// check that sum received from slave console equals checksum calculated in main cycle
|
|
1290
|
+
if (data == checksum) {
|
|
1291
|
+
// data successfully received by slave SEGA
|
|
1292
|
+
// reset start index of data to transmit and end index in buffer
|
|
1293
|
+
// since slave console received all data successfully
|
|
1294
|
+
LCP_clearSendHeadAndTail();
|
|
1295
|
+
} else {
|
|
1296
|
+
// 0x80 - checksum calculated by master console <> checksum received from slave console
|
|
1297
|
+
LCP_error |= 0x80;
|
|
1298
|
+
// don't interrupt function since no timeout occurred, try to receive data from slave console
|
|
1299
|
+
// next time data will be sent again!
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// reset checksum
|
|
1303
|
+
checksum = 0;
|
|
1304
|
+
|
|
1305
|
+
// receive first 2 bytes from slave console
|
|
1306
|
+
// size contains 2 bytes received from slave console since packet data size is stored there
|
|
1307
|
+
size = LCP_Receive();
|
|
1308
|
+
|
|
1309
|
+
if (LCP_timeOut) {
|
|
1310
|
+
// 0x90 - error calling size = LCP_Receive() - reception of 2 bytes (packet size) from slave console
|
|
1311
|
+
LCP_error |= 0x90;
|
|
1312
|
+
LCP_masterCycleEnd();
|
|
1313
|
+
// Exit function with error, LCP_error != 0
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
// current index to start of data in LCP_ReceivePacket
|
|
1318
|
+
head = LCP_ReceiveTail;
|
|
1319
|
+
|
|
1320
|
+
// receive data if size greater than 0 (there is something to receive)
|
|
1321
|
+
for (u16 i = 0; i < size; i++) {
|
|
1322
|
+
// receive next 2 bytes from slave console via Link Cable
|
|
1323
|
+
data = LCP_Receive();
|
|
1324
|
+
|
|
1325
|
+
if (LCP_timeOut) {
|
|
1326
|
+
// 0xA0 - error calling data = LCP_Receive() - reception of 2 bytes (packet data) from slave console
|
|
1327
|
+
LCP_error |= 0xA0;
|
|
1328
|
+
LCP_masterCycleEnd();
|
|
1329
|
+
// Exit function with error, LCP_error != 0
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// calculate checksum
|
|
1334
|
+
checksum += data;
|
|
1335
|
+
|
|
1336
|
+
// save read 2 bytes into received objects data packet
|
|
1337
|
+
LCP_ReceivePacket[head] = data;
|
|
1338
|
+
|
|
1339
|
+
// change current position index in received objects data packet
|
|
1340
|
+
head++;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// receive checksum from slave console
|
|
1344
|
+
data = LCP_Receive();
|
|
1345
|
+
|
|
1346
|
+
if (LCP_timeOut) {
|
|
1347
|
+
// 0xB0 - error calling data = LCP_Receive() - main cycle of receiving 2 bytes (checksum) from slave console
|
|
1348
|
+
LCP_error |= 0xB0;
|
|
1349
|
+
LCP_masterCycleEnd();
|
|
1350
|
+
// Exit function with error, LCP_error != 0
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
// check that received checksum from slave console equals calculated one
|
|
1355
|
+
if (data == checksum) {
|
|
1356
|
+
// set data end index to current index in received data buffer
|
|
1357
|
+
LCP_ReceiveTail = head;
|
|
1358
|
+
} else {
|
|
1359
|
+
// 0xC0 - checksum calculated by master console <> checksum received from slave console
|
|
1360
|
+
LCP_error |= 0xC0;
|
|
1361
|
+
// therefore don't move end index for received data packet LCP_ReceivePacket
|
|
1362
|
+
// but since no timeouts occurred, continue function execution
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
// completion of data reception from slave console
|
|
1366
|
+
LCP_endReceiveCycle();
|
|
1367
|
+
|
|
1368
|
+
if (LCP_timeOut) {
|
|
1369
|
+
// 0xD0 - error calling LCP_endReceiveCycle() - end of data reception cycle from slave console
|
|
1370
|
+
LCP_error |= 0xD0;
|
|
1371
|
+
LCP_masterCycleEnd();
|
|
1372
|
+
// Exit function with error, LCP_error != 0
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// start of data transmission to slave console from master
|
|
1377
|
+
LCP_startSendCycle();
|
|
1378
|
+
|
|
1379
|
+
if (LCP_timeOut) {
|
|
1380
|
+
// 0xE0 - error calling LCP_startSendCycle() - start of checksum transmission from master to slave console
|
|
1381
|
+
LCP_error |= 0xE0;
|
|
1382
|
+
LCP_masterCycleEnd();
|
|
1383
|
+
// Exit function with error, LCP_error != 0
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// send checksum to slave console from master
|
|
1388
|
+
LCP_send(checksum);
|
|
1389
|
+
|
|
1390
|
+
if (LCP_timeOut) {
|
|
1391
|
+
// 0xF0 - error calling LCP_send(checksum) - transmission of checksum from master to slave
|
|
1392
|
+
LCP_error |= 0xF0;
|
|
1393
|
+
LCP_masterCycleEnd();
|
|
1394
|
+
// Exit function with error, LCP_error != 0
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
// finish data transmission
|
|
1399
|
+
LCP_endSendCycle();
|
|
1400
|
+
|
|
1401
|
+
// finish packet transmission/reception
|
|
1402
|
+
LCP_masterCycleEnd();
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* End of data transmission and reception cycle via Link Cable for SEGA master console
|
|
1408
|
+
* switches console's 2nd port to data reception mode via Link Cable, on all pins except pin 5
|
|
1409
|
+
* Set bit 5 in LCP_Ctrl to 1, others to 0, which means we no longer transmit data in bits 0-3
|
|
1410
|
+
* Set bit 5 in LCP_Data to 1 for our master console, on the other console (slave) bit 6 will also become 1
|
|
1411
|
+
* re-enables processing of all interrupts
|
|
1412
|
+
*/
|
|
1413
|
+
static void LCP_masterCycleEnd() {
|
|
1414
|
+
// switch port to data reception mode
|
|
1415
|
+
// Interrupt on SYN line signal disabled, bit 7 = 0.
|
|
1416
|
+
// data line PC5 in output mode (transmission), bit 5 = 1.
|
|
1417
|
+
// data lines PC6, PC4, PC3, PC2, PC1, PC0 in input mode (reception). Corresponding bits = 0
|
|
1418
|
+
// enable pins 0-3 of 2nd controller port for data reception
|
|
1419
|
+
// pin 5 for signaling events to other console (on other console bit 6 of LCP_Data will equal what we set in our 5th bit)
|
|
1420
|
+
// pin 6 signal from other console about events (other console should change bit 5 of its LCP_Data so that our 6th bit changes)
|
|
1421
|
+
LCP_Ctrl = LCP_BIT5;
|
|
1422
|
+
|
|
1423
|
+
// set bit 5 in LCP_Data to 1
|
|
1424
|
+
LCP_Data |= (1 << 5);
|
|
1425
|
+
|
|
1426
|
+
// enable processing of all interrupts
|
|
1427
|
+
SYS_enableInts();
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
/**
|
|
1432
|
+
* Reception and then transmission cycle via Link Cable for SEGA slave console
|
|
1433
|
+
* This is an EX-INT external interrupt handler - External interrupt in SEGA documentation
|
|
1434
|
+
* It MUST NOT be called directly from game code!
|
|
1435
|
+
*
|
|
1436
|
+
* This function will be set as EX-INT external interrupt handler when LCP_open() is called from YOUR game code
|
|
1437
|
+
* and will be disabled as external interrupt handler when LCP_close() is called from YOUR game code
|
|
1438
|
+
*
|
|
1439
|
+
* Function call always occurs asynchronously, interrupting your game code execution at random, unpredictable time for main game code!
|
|
1440
|
+
*
|
|
1441
|
+
* At the very beginning, it disables all interrupt processing and resets LCP_timeOut and LCP_error to 0
|
|
1442
|
+
*
|
|
1443
|
+
* Error codes (error code = LCP_error & 0x0F00):
|
|
1444
|
+
* 0x100 - error calling LCP_slaveCycle() - second console port not open for data exchange
|
|
1445
|
+
* 0x200 - error calling LCP_startReceiveCycle() - start of data reception from master console
|
|
1446
|
+
* 0x300 - error calling size = LCP_Receive() - receiving size of transmitted data from master console
|
|
1447
|
+
* 0x400 - error calling data = LCP_Receive() - receiving next 2 bytes of packet data from master console
|
|
1448
|
+
* 0x500 - error calling data = LCP_Receive() - receiving checksum from master console
|
|
1449
|
+
* 0x600 - error calling LCP_endReceiveCycle() - end of data reception from master console
|
|
1450
|
+
* 0x700 - error calling LCP_startSendCycle() - start of data transmission from slave console
|
|
1451
|
+
* 0x800 - error calling LCP_send(checksum) - transmitting checksum from slave console
|
|
1452
|
+
* 0x900 - error calling LCP_send(size) - transmitting size of packet to be sent from slave console
|
|
1453
|
+
* 0xA00 - error calling LCP_send(data) - transmitting next 2 bytes of packet data from slave console
|
|
1454
|
+
* 0xB00 - error calling LCP_send(checksum) - transmitting checksum from slave console
|
|
1455
|
+
* 0xC00 - error calling LCP_endSendCycle() - end of data transmission from slave console
|
|
1456
|
+
* 0xD00 - error calling LCP_startReceiveCycle() - start of data reception from master console
|
|
1457
|
+
* 0xE00 - error calling data = LCP_Receive() - receiving checksum from master console
|
|
1458
|
+
*
|
|
1459
|
+
* Error codes (error code = LCP_error & 0x00F0):
|
|
1460
|
+
* 0x80 - checksum calculated by slave console <> checksum received from master console
|
|
1461
|
+
* 0xC0 - checksum calculated by slave console <> checksum received from master console
|
|
1462
|
+
*/
|
|
1463
|
+
static void LCP_slaveCycle() {
|
|
1464
|
+
// size of transmitted or received data
|
|
1465
|
+
s16 size;
|
|
1466
|
+
// checksum for verifying transmitted data
|
|
1467
|
+
u16 checksum = 0;
|
|
1468
|
+
// current index of transmitted or received data
|
|
1469
|
+
u16 head = LCP_ReceiveTail;
|
|
1470
|
+
// transmitted or received 2 bytes (16 bits) via Link Cable
|
|
1471
|
+
u16 data;
|
|
1472
|
+
|
|
1473
|
+
LCP_error = 0;
|
|
1474
|
+
LCP_timeOut = 0;
|
|
1475
|
+
|
|
1476
|
+
// switch port to data reading mode
|
|
1477
|
+
// Interrupt on SYN line signal disabled, bit 7 = 0.
|
|
1478
|
+
// data line PC5 in output mode (transmission), bit 5 = 1.
|
|
1479
|
+
// data lines PC6, PC4, PC3, PC2, PC1, PC0 in input mode (reception). Corresponding bits = 0
|
|
1480
|
+
// enable pins 0-3 of 2nd controller port for data reception
|
|
1481
|
+
// pin 5 for signaling events to other console (on other console bit 6 of LCP_Data will equal what we set in our 5th bit)
|
|
1482
|
+
// pin 6 signal from other console about events (other console should change bit 5 of its LCP_Data so that our 6th bit changes)
|
|
1483
|
+
LCP_Ctrl = LCP_BIT5;
|
|
1484
|
+
|
|
1485
|
+
if (!LCP_portOpen) {
|
|
1486
|
+
// port not open
|
|
1487
|
+
// 0x100 - error calling LCP_slaveCycle() - second console port not open for data exchange
|
|
1488
|
+
LCP_error |= 0x100;
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
// disable all interrupt processing
|
|
1493
|
+
SYS_disableInts();
|
|
1494
|
+
|
|
1495
|
+
// start data reception cycle for our slave console via Link Cable from master console
|
|
1496
|
+
LCP_startReceiveCycle();
|
|
1497
|
+
|
|
1498
|
+
if (LCP_timeOut) {
|
|
1499
|
+
// 0x200 - error calling LCP_startReceiveCycle() - start of data reception from master console
|
|
1500
|
+
LCP_error |= 0x200;
|
|
1501
|
+
LCP_slaveCycleEnd();
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// first 2 bytes of data - size of packet transmitted to our console (slave) via Link Cable from master console
|
|
1506
|
+
size = LCP_Receive();
|
|
1507
|
+
|
|
1508
|
+
if (LCP_timeOut) {
|
|
1509
|
+
// 0x300 - error calling size = LCP_Receive() - receiving size of transmitted data from master console
|
|
1510
|
+
LCP_error |= 0x300;
|
|
1511
|
+
LCP_slaveCycleEnd();
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// receive packet body from master console via Link Cable by our console (slave)
|
|
1516
|
+
for (u16 i = 0; i < size; i++) {
|
|
1517
|
+
// get 2 bytes of data into data by our slave console via Link Cable from master console
|
|
1518
|
+
data = LCP_Receive();
|
|
1519
|
+
|
|
1520
|
+
if (LCP_timeOut) {
|
|
1521
|
+
// 0x400 - error calling data = LCP_Receive() - receiving next 2 bytes of packet data from master console
|
|
1522
|
+
LCP_error |= 0x400;
|
|
1523
|
+
LCP_slaveCycleEnd();
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// calculate verification sum
|
|
1528
|
+
checksum += data;
|
|
1529
|
+
// save received 2 bytes into reception packet at index head
|
|
1530
|
+
LCP_ReceivePacket[head] = data;
|
|
1531
|
+
// increase head - start index of data in LCP_ReceivePacket by 1
|
|
1532
|
+
head++;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
// after packet body, receive checksum of sent data in data from master console
|
|
1536
|
+
data = LCP_Receive();
|
|
1537
|
+
|
|
1538
|
+
if (LCP_timeOut) {
|
|
1539
|
+
// 0x500 - error calling data = LCP_Receive() - receiving checksum from master console
|
|
1540
|
+
LCP_error |= 0x500;
|
|
1541
|
+
LCP_slaveCycleEnd();
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
// if verification sum received from master console in data equals our calculated one,
|
|
1546
|
+
// then save head index into global variable LCP_ReceiveTail - end index of received packet data
|
|
1547
|
+
// from master console
|
|
1548
|
+
if (data == checksum) {
|
|
1549
|
+
LCP_ReceiveTail = head;
|
|
1550
|
+
} else {
|
|
1551
|
+
// if LCP_error & 0x00F0 = 0x80 - checksum calculated by slave console <> checksum received from master console
|
|
1552
|
+
LCP_error |= 0x80;
|
|
1553
|
+
// don't interrupt function since no timeout occurred, try to send data from our slave console to master
|
|
1554
|
+
// and checksum calculated by our console, so master understands that data needs to be sent again
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
// end of data reception cycle for our slave console from master console via Link Cable
|
|
1558
|
+
LCP_endReceiveCycle();
|
|
1559
|
+
|
|
1560
|
+
if (LCP_timeOut) {
|
|
1561
|
+
// 0x600 - error calling LCP_endReceiveCycle() - end of data reception from master console
|
|
1562
|
+
LCP_error |= 0x600;
|
|
1563
|
+
LCP_slaveCycleEnd();
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
// start data transmission cycle from our slave console via Link Cable to master console
|
|
1568
|
+
LCP_startSendCycle();
|
|
1569
|
+
|
|
1570
|
+
if (LCP_timeOut) {
|
|
1571
|
+
// 0x700 - error calling LCP_startSendCycle() - start of data transmission from slave console
|
|
1572
|
+
LCP_error |= 0x700;
|
|
1573
|
+
LCP_slaveCycleEnd();
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
// transmit calculated checksum to master console from our slave console via Link Cable
|
|
1578
|
+
LCP_send(checksum);
|
|
1579
|
+
|
|
1580
|
+
if (LCP_timeOut) {
|
|
1581
|
+
// 0x800 - error calling LCP_send(checksum) - transmitting checksum from slave console
|
|
1582
|
+
LCP_error |= 0x800;
|
|
1583
|
+
LCP_slaveCycleEnd();
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// calculate size of packet to transmit
|
|
1588
|
+
size = LCP_sendTail - LCP_sendHead;
|
|
1589
|
+
if (size < 0) {
|
|
1590
|
+
size = 0;
|
|
1591
|
+
LCP_clearSendHeadAndTail();
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
// transmit packet body size from our slave console via Link Cable to master console
|
|
1595
|
+
LCP_send(size);
|
|
1596
|
+
|
|
1597
|
+
if (LCP_timeOut) {
|
|
1598
|
+
// 0x900 - error calling LCP_send(size) - transmitting size of packet to be sent from slave console
|
|
1599
|
+
LCP_error |= 0x900;
|
|
1600
|
+
LCP_slaveCycleEnd();
|
|
1601
|
+
return;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
// reset checksum value
|
|
1605
|
+
checksum = 0;
|
|
1606
|
+
|
|
1607
|
+
// set head index to start of packet to be transmitted
|
|
1608
|
+
head = LCP_sendHead;
|
|
1609
|
+
|
|
1610
|
+
// transmit packet body from our console (slave) via Link Cable to master console
|
|
1611
|
+
for (u16 i = 0; i < size; i++) {
|
|
1612
|
+
// write 2 bytes to data that we'll transmit from slave console packet
|
|
1613
|
+
data = LCP_sendPacket[head];
|
|
1614
|
+
|
|
1615
|
+
// increase head index by 1 for start of data in LCP_sendPacket to be sent
|
|
1616
|
+
head++;
|
|
1617
|
+
|
|
1618
|
+
// calculate verification sum
|
|
1619
|
+
checksum += data;
|
|
1620
|
+
|
|
1621
|
+
// transmit 2 bytes of packet body from our slave console via Link Cable to master console
|
|
1622
|
+
LCP_send(data);
|
|
1623
|
+
|
|
1624
|
+
if (LCP_timeOut) {
|
|
1625
|
+
// 0xA00 - error calling LCP_send(data) - transmitting next 2 bytes of packet data from slave console
|
|
1626
|
+
LCP_error |= 0xA00;
|
|
1627
|
+
LCP_slaveCycleEnd();
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
// after packet body, transmit checksum of sent packet data
|
|
1633
|
+
// from our slave console via Link Cable to master console
|
|
1634
|
+
LCP_send(checksum);
|
|
1635
|
+
|
|
1636
|
+
if (LCP_timeOut) {
|
|
1637
|
+
// 0xB00 - error calling LCP_send(checksum) - transmitting checksum from slave console
|
|
1638
|
+
LCP_error |= 0xB00;
|
|
1639
|
+
LCP_slaveCycleEnd();
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
// complete data transmission cycle from our slave console via Link Cable to master console
|
|
1644
|
+
LCP_endSendCycle();
|
|
1645
|
+
|
|
1646
|
+
if (LCP_timeOut) {
|
|
1647
|
+
// 0xC00 - error calling LCP_endSendCycle() - end of data transmission from slave console
|
|
1648
|
+
LCP_error |= 0xC00;
|
|
1649
|
+
LCP_slaveCycleEnd();
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
// start data reception cycle for our slave console via Link Cable from master console
|
|
1654
|
+
LCP_startReceiveCycle();
|
|
1655
|
+
|
|
1656
|
+
if (LCP_timeOut) {
|
|
1657
|
+
// 0xD00 - error calling LCP_startReceiveCycle() - start of data reception from master console
|
|
1658
|
+
LCP_error |= 0xD00;
|
|
1659
|
+
LCP_slaveCycleEnd();
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
// receive checksum of received data by master console via Link Cable from our slave console
|
|
1664
|
+
data = LCP_Receive();
|
|
1665
|
+
|
|
1666
|
+
if (LCP_timeOut) {
|
|
1667
|
+
// 0xE00 - error calling data = LCP_Receive() - receiving checksum from master console
|
|
1668
|
+
LCP_error |= 0xE00;
|
|
1669
|
+
LCP_slaveCycleEnd();
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
if (data == checksum) {
|
|
1674
|
+
// if received checksum in data from master console equals transmitted and calculated by our console (slave),
|
|
1675
|
+
// then set packet start index and packet end index to 0 (everything successfully sent)
|
|
1676
|
+
LCP_clearSendHeadAndTail();
|
|
1677
|
+
} else {
|
|
1678
|
+
// 0xC0 - checksum calculated by slave console <> checksum received from master console
|
|
1679
|
+
LCP_error |= 0xC0;
|
|
1680
|
+
// therefore don't move start index for received data packet LCP_sendPacket
|
|
1681
|
+
// but since no timeouts occurred, continue function execution
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
// end of data reception cycle for our slave console from master console via Link Cable
|
|
1685
|
+
LCP_endReceiveCycle();
|
|
1686
|
+
|
|
1687
|
+
// end of console interaction in this cycle from our slave side
|
|
1688
|
+
LCP_slaveCycleEnd();
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* End of data reception and then transmission cycle via Link Cable for SEGA slave console
|
|
1694
|
+
* switches console's 2nd port to data reception mode via Link Cable, on all pins except pin 5
|
|
1695
|
+
* Set bit 5 in LCP_Ctrl to 1, others to 0, which means we no longer transmit data in bits 0-3
|
|
1696
|
+
* Set bit 5 in LCP_Data to 1 for our slave console, on the other console (master) bit 6 will also become 1
|
|
1697
|
+
* re-enables processing of all interrupts
|
|
1698
|
+
*
|
|
1699
|
+
* Error codes (error code = LCP_error & 0x0F00):
|
|
1700
|
+
* 0xF00 - error calling LCP_slaveCycleEnd() - end of data reception cycle from slave console
|
|
1701
|
+
*/
|
|
1702
|
+
static void LCP_slaveCycleEnd() {
|
|
1703
|
+
// switch port to data reading mode
|
|
1704
|
+
// Interrupt on SYN line signal disabled, bit 7 = 0.
|
|
1705
|
+
// data line PC5 in output mode (transmission), bit 5 = 1.
|
|
1706
|
+
// data lines PC6, PC4, PC3, PC2, PC1, PC0 in input mode (reception). Corresponding bits = 0
|
|
1707
|
+
// enable pins 0-3 of 2nd controller port for data reception
|
|
1708
|
+
// pin 5 for signaling events to other console (on other console bit 6 of LCP_Data will equal what we set in our 5th bit)
|
|
1709
|
+
// pin 6 signal from other console about events (other console should change bit 5 of its LCP_Data so that our 6th bit changes)
|
|
1710
|
+
LCP_Ctrl = LCP_BIT5;
|
|
1711
|
+
|
|
1712
|
+
// set bit 5 in LCP_Data to 1
|
|
1713
|
+
LCP_Data |= (1 << 5);
|
|
1714
|
+
|
|
1715
|
+
u16 timeout = LCP_TIME_OUT;
|
|
1716
|
+
do {
|
|
1717
|
+
timeout--; // Subtract 1 from timeout
|
|
1718
|
+
if (timeout == 0) {
|
|
1719
|
+
LCP_timeOut++;
|
|
1720
|
+
// 0xF00 - error calling LCP_slaveCycleEnd() - end of data reception cycle from slave console
|
|
1721
|
+
LCP_error |= 0xF00;
|
|
1722
|
+
// If timeout reached 0, exit loop
|
|
1723
|
+
break;
|
|
1724
|
+
}
|
|
1725
|
+
// wait until bit 6 becomes 1
|
|
1726
|
+
} while (!(LCP_Data & (1 << 6)));
|
|
1727
|
+
|
|
1728
|
+
// ready for data exchange via console's 2nd port upon EX-INT interrupt occurrence
|
|
1729
|
+
// first reading data from port, then writing to port in external interrupt handler LCP_slaveCycle()
|
|
1730
|
+
// Interrupt on SYN line signal enabled, bit 7 = 1.
|
|
1731
|
+
// data line PC5 in output mode (transmission), bit 5 = 1.
|
|
1732
|
+
// data lines PC6, PC4, PC3, PC2, PC1, PC0 in input mode (reception). Corresponding bits = 0
|
|
1733
|
+
// enable pins 0-3 of 2nd controller port for data reception
|
|
1734
|
+
// pin 5 for signal that data is received by our console (on other console this will be bit 6 of LCP_Data)
|
|
1735
|
+
// pin 6 signal that data was sent by other console (other console should change bit 5 of its LCP_Data)
|
|
1736
|
+
LCP_Ctrl = LCP_BIT7_AND_BIT5;
|
|
1737
|
+
|
|
1738
|
+
// enable processing of all interrupts
|
|
1739
|
+
SYS_enableInts();
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
|
|
1743
|
+
/**
|
|
1744
|
+
* Error in data transmission via SEGA Link Cable
|
|
1745
|
+
*
|
|
1746
|
+
* If 0x0000, no errors occurred! Value ranges in binary format
|
|
1747
|
+
* Lower 4 bits of low byte - data reception errors via Link Cable (0x0001 - 0x000F) 000000000000xxxx
|
|
1748
|
+
* Upper 4 bits of low byte - data transmission errors via Link Cable (0x0010 - 0x00F0) 00000000xxxx0000
|
|
1749
|
+
* Lower 4 bits of high byte - packet reception or transmission errors (0x0100 - 0x0F00) 0000xxxx00000000
|
|
1750
|
+
* Upper 4 bits of high byte - object extraction errors from packet (0x1000 - 0xF000) xxxx000000000000
|
|
1751
|
+
*
|
|
1752
|
+
* return LCP_error
|
|
1753
|
+
*/
|
|
1754
|
+
u16 LCP_getError() {
|
|
1755
|
+
return LCP_error;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
#endif // MODULE_LINK_CABLE
|