git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit b72763b88d34a9adcfa9ea66f55cf8d1e9dacae9
parent 4e65864e94cf68d0ae0800fb88ce5eb50665cc66
Author: Toxa <56631470+untoxa@users.noreply.github.com>
Date:   Mon, 16 Aug 2021 00:05:07 +0300

Merge pull request #227 from gbdk-2020/feature/ap

merge feature/ap branch
Diffstat:
M.gitignore3+++
MMakefile58+++++++++++++++++++++++++++++++++++++++++++++-------------
Mgbdk-lib/Makefile.common6+++---
Agbdk-lib/examples/ap/Makefile18++++++++++++++++++
Agbdk-lib/examples/ap/Makefile.rgbds92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks/Makefile63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks/bank_0.c4++++
Agbdk-lib/examples/ap/banks/bank_1.c10++++++++++
Agbdk-lib/examples/ap/banks/bank_2.c10++++++++++
Agbdk-lib/examples/ap/banks/bank_3.c10++++++++++
Agbdk-lib/examples/ap/banks/banks.c61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_autobank/Makefile70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_autobank/banks.c82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_autobank/srcfile_1.c62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_autobank/srcfile_2.c302++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_autobank/srcfile_3.c26++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_autobank/srcfile_4_not-autobanked.c343+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_farptr/Makefile34++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_farptr/bank2code.c21+++++++++++++++++++++
Agbdk-lib/examples/ap/banks_farptr/banks_farptr.c50++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_nonintrinsic/Makefile26++++++++++++++++++++++++++
Agbdk-lib/examples/ap/banks_nonintrinsic/banks_nonintrinsic.c90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/bcd/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/bcd/bcd.c38++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/bgb_debug/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/bgb_debug/bgb_debug.c147+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/colorbar/Makefile30++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/colorbar/bar_c.c102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/colorbar/bar_c.gbr0
Agbdk-lib/examples/ap/colorbar/bar_c.h105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/colorbar/bar_m.c62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/colorbar/bar_m.gbm0
Agbdk-lib/examples/ap/colorbar/bar_m.h24++++++++++++++++++++++++
Agbdk-lib/examples/ap/colorbar/colorbar.c73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/comm/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/comm/comm.c90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/crash/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/crash/crash.c8++++++++
Agbdk-lib/examples/ap/dscan/Makefile24++++++++++++++++++++++++
Agbdk-lib/examples/ap/dscan/bkg.c238+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/dscan/bkg.gbr0
Agbdk-lib/examples/ap/dscan/bkg.h105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/dscan/bkg_c.c62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/dscan/bkg_c.gbm0
Agbdk-lib/examples/ap/dscan/bkg_m.c62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/dscan/bkg_m.gbm0
Agbdk-lib/examples/ap/dscan/dscan.c751+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/dscan/fore.c306+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/dscan/fore.gbr0
Agbdk-lib/examples/ap/dscan/fore.h105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/filltest/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/filltest/filltest.c60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/fonts/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/fonts/fonts.c56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/galaxy/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/galaxy/galaxy.c632+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/Makefile24++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/brk_btn.c41+++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/brk_btn.gbr0
Agbdk-lib/examples/ap/gb-dtmf/cursor.c39+++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/cursor.gbr0
Agbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.c123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.gbr0
Agbdk-lib/examples/ap/gb-dtmf/frm_lcd.c41+++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/frm_lcd.gbr0
Agbdk-lib/examples/ap/gb-dtmf/gb-dtmf.c715+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/key_num.c69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/key_num.gbr0
Agbdk-lib/examples/ap/gb-dtmf/prs_btn.c41+++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gb-dtmf/prs_btn.gbr0
Agbdk-lib/examples/ap/gbdecompress/Makefile33+++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gbdecompress/Readme.md8++++++++
Agbdk-lib/examples/ap/gbdecompress/main.c41+++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gbdecompress/monalisa.gbm0
Agbdk-lib/examples/ap/gbdecompress/monalisa_map.c66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gbdecompress/monalisa_map.h32++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gbdecompress/monalisa_tiles.gbr0
Agbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.c467+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.h107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/incbin/Makefile60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/incbin/Readme.md8++++++++
Agbdk-lib/examples/ap/incbin/res/blanktile.bin0
Agbdk-lib/examples/ap/incbin/res/blanktile.png0
Agbdk-lib/examples/ap/incbin/res/gbdk2020.bin0
Agbdk-lib/examples/ap/incbin/res/gbdk2020.png0
Agbdk-lib/examples/ap/incbin/res/gbdk2020_map.bin0
Agbdk-lib/examples/ap/incbin/src/main.c58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/irq/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/irq/irq.c62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/large_map/Makefile11+++++++++++
Agbdk-lib/examples/ap/large_map/Readme.md14++++++++++++++
Agbdk-lib/examples/ap/large_map/bigmap_map.c1661+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/large_map/bigmap_map.h32++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/large_map/bigmap_tiles.c512+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/large_map/bigmap_tiles.h107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/large_map/large_map.c97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/lcd_isr_wobble/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/lcd_isr_wobble/lcd_isr_wobble.c29+++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/linkerfile/Makefile68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/linkerfile/Readme.md18++++++++++++++++++
Agbdk-lib/examples/ap/linkerfile/src/main.c15+++++++++++++++
Agbdk-lib/examples/ap/metasprites/Makefile36++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/metasprites/Readme.md20++++++++++++++++++++
Agbdk-lib/examples/ap/metasprites/metasprites.c153+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/metasprites/sprite.png0
Agbdk-lib/examples/ap/paint/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/paint/paint.c528+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/ram_function/Makefile32++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/ram_function/ram_fn.c71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/rand/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/rand/rand.c59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/rpn/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/rpn/rpn.c102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/samptest/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/samptest/samptest.c1639+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/scroller/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/scroller/text_scroller.c73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/sgb_border/Makefile11+++++++++++
Agbdk-lib/examples/ap/sgb_border/border.c14++++++++++++++
Agbdk-lib/examples/ap/sgb_border/border_data.c192+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/sgb_border/border_data.h15+++++++++++++++
Agbdk-lib/examples/ap/sgb_border/sgb_border.c69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/sgb_border/sgb_border.h16++++++++++++++++
Agbdk-lib/examples/ap/sgb_multiplayer/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/sgb_multiplayer/sgb_multiplayer.c44++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/sgb_pong/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/sgb_pong/sgb_pong.c145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/sound/Makefile17+++++++++++++++++
Agbdk-lib/examples/ap/sound/readme.md13+++++++++++++
Agbdk-lib/examples/ap/sound/sound.c1067+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/space/Makefile18++++++++++++++++++
Agbdk-lib/examples/ap/space/space.s1296+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/template_minimal/Makefile33+++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/template_minimal/Readme.md7+++++++
Agbdk-lib/examples/ap/template_minimal/main.c17+++++++++++++++++
Agbdk-lib/examples/ap/template_subfolders/Makefile61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/template_subfolders/Readme.md18++++++++++++++++++
Agbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbm0
Agbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbr0
Agbdk-lib/examples/ap/template_subfolders/res/dungeon_map.c133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/template_subfolders/res/dungeon_map.h28++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.c188+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.h103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/ap/template_subfolders/src/main.c31+++++++++++++++++++++++++++++++
Rgbdk-lib/examples/gb/fprpn/Makefile -> gbdk-lib/examples/broken/fprpn/Makefile0
Rgbdk-lib/examples/gb/fprpn/fprpn.c -> gbdk-lib/examples/broken/fprpn/fprpn.c0
Mgbdk-lib/examples/gb/dscan/Makefile6+-----
Mgbdk-lib/examples/gb/lcd_isr_wobble/lcd_isr_wobble.c2+-
Mgbdk-lib/examples/gb/scroller/text_scroller.c2+-
Agbdk-lib/examples/gb/simple_physics/Makefile17+++++++++++++++++
Agbdk-lib/examples/gb/simple_physics/phys.c89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/gg/Makefile18++++++++++++++++++
Agbdk-lib/examples/gg/smoke/Makefile30++++++++++++++++++++++++++++++
Agbdk-lib/examples/gg/smoke/assets.c46++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/gg/smoke/banked.c8++++++++
Agbdk-lib/examples/gg/smoke/smoketest.c55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/sms/Makefile18++++++++++++++++++
Agbdk-lib/examples/sms/smoke/Makefile30++++++++++++++++++++++++++++++
Agbdk-lib/examples/sms/smoke/assets.c46++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/examples/sms/smoke/banked.c8++++++++
Agbdk-lib/examples/sms/smoke/ram_bank0.s7+++++++
Agbdk-lib/examples/sms/smoke/ram_bank1.s7+++++++
Agbdk-lib/examples/sms/smoke/smoketest.c87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mgbdk-lib/include/asm/types.h11++++++++++-
Agbdk-lib/include/asm/z80/provides.h4++++
Agbdk-lib/include/asm/z80/stdarg.h18++++++++++++++++++
Agbdk-lib/include/asm/z80/types.h46++++++++++++++++++++++++++++++++++++++++++++++
Mgbdk-lib/include/gb/gb.h15++++++++++++++-
Mgbdk-lib/include/gb/hardware.h50+++++++++++++++++++++++++++++++++++++++++++++++++-
Agbdk-lib/include/sms/hardware.h175+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/include/sms/sms.h412+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mgbdk-lib/libc/Makefile9++++-----
Mgbdk-lib/libc/asm/gbz80/Makefile4+++-
Agbdk-lib/libc/asm/gbz80/arand.s126+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/gbz80/bcd.s233+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/gbz80/rand.s116+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/Makefile26++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/__itoa.s231+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/__ltoa.s254+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/__sdcc_call_hl.s37+++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/__sdcc_call_iy.s37+++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/__sdcc_critical.s54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/__strreverse.s61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/__uitobcd.s87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/__ultobcd.s122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/abs.s61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/atomic_flag_test_and_set.s44++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/crtenter.s41+++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/divmixed.s58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/divsigned.s137+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/divunsigned.s143+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/heap.s44++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/memcpy.s53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/memmove.s65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/modmixed.s62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/modsigned.s57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/modunsigned.s61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/mul.s74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/mulchar.s79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/setjmp.s95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/strcpy.s48++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/asm/z80/strlen.s47+++++++++++++++++++++++++++++++++++++++++++++++
Dgbdk-lib/libc/bcd.c220-------------------------------------------------------------------------------
Dgbdk-lib/libc/gb/Makefile56--------------------------------------------------------
Dgbdk-lib/libc/gb/arand.s129-------------------------------------------------------------------------------
Dgbdk-lib/libc/gb/cgb_palettes.s78------------------------------------------------------------------------------
Dgbdk-lib/libc/gb/color.s24------------------------
Dgbdk-lib/libc/gb/crt0.s497-------------------------------------------------------------------------------
Dgbdk-lib/libc/gb/drawing.s1771-------------------------------------------------------------------------------
Dgbdk-lib/libc/gb/drawing_isr.s23-----------------------
Dgbdk-lib/libc/gb/font.s705-------------------------------------------------------------------------------
Dgbdk-lib/libc/gb/global.s502-------------------------------------------------------------------------------
Dgbdk-lib/libc/gb/input.s647-------------------------------------------------------------------------------
Dgbdk-lib/libc/gb/rand.s120-------------------------------------------------------------------------------
Mgbdk-lib/libc/rules-asxxxx.mk6++++++
Rgbdk-lib/libc/gb/___sdcc_bcall.s -> gbdk-lib/libc/targets/gbz80/___sdcc_bcall.s0
Rgbdk-lib/libc/gb/___sdcc_bcall_ehl.s -> gbdk-lib/libc/targets/gbz80/___sdcc_bcall_ehl.s0
Agbdk-lib/libc/targets/gbz80/ap/Makefile52++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/gbz80/ap/crt0.s503+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/gbz80/ap/global.s508+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/gbz80/ap/sfr.s111+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rgbdk-lib/libc/gb/bgb_emu.s -> gbdk-lib/libc/targets/gbz80/bgb_emu.s0
Rgbdk-lib/libc/gb/bgb_emu_printf.s -> gbdk-lib/libc/targets/gbz80/bgb_emu_printf.s0
Rgbdk-lib/libc/gb/cgb.s -> gbdk-lib/libc/targets/gbz80/cgb.s0
Rgbdk-lib/libc/gb/cgb_compat.s -> gbdk-lib/libc/targets/gbz80/cgb_compat.s0
Agbdk-lib/libc/targets/gbz80/cgb_palettes.s78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rgbdk-lib/libc/gb/clock.s -> gbdk-lib/libc/targets/gbz80/clock.s0
Agbdk-lib/libc/targets/gbz80/color.s24++++++++++++++++++++++++
Rgbdk-lib/libc/gb/cpy_data.s -> gbdk-lib/libc/targets/gbz80/cpy_data.s0
Rgbdk-lib/libc/gb/crash_handler.s -> gbdk-lib/libc/targets/gbz80/crash_handler.s0
Rgbdk-lib/libc/gb/delay.s -> gbdk-lib/libc/targets/gbz80/delay.s0
Rgbdk-lib/libc/gb/digits.c -> gbdk-lib/libc/targets/gbz80/digits.c0
Agbdk-lib/libc/targets/gbz80/drawing.s1770+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/gbz80/drawing_isr.s23+++++++++++++++++++++++
Rgbdk-lib/libc/gb/f_ibm_full.s -> gbdk-lib/libc/targets/gbz80/f_ibm_full.s0
Rgbdk-lib/libc/gb/f_ibm_sh.s -> gbdk-lib/libc/targets/gbz80/f_ibm_sh.s0
Rgbdk-lib/libc/gb/f_italic.s -> gbdk-lib/libc/targets/gbz80/f_italic.s0
Rgbdk-lib/libc/gb/f_min.s -> gbdk-lib/libc/targets/gbz80/f_min.s0
Rgbdk-lib/libc/gb/f_spect.s -> gbdk-lib/libc/targets/gbz80/f_spect.s0
Rgbdk-lib/libc/gb/far_ptr.s -> gbdk-lib/libc/targets/gbz80/far_ptr.s0
Rgbdk-lib/libc/gb/fill_rect.s -> gbdk-lib/libc/targets/gbz80/fill_rect.s0
Rgbdk-lib/libc/gb/fill_rect_bk.s -> gbdk-lib/libc/targets/gbz80/fill_rect_bk.s0
Rgbdk-lib/libc/gb/fill_rect_wi.s -> gbdk-lib/libc/targets/gbz80/fill_rect_wi.s0
Agbdk-lib/libc/targets/gbz80/font.s705+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/gbz80/gb/Makefile52++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/gbz80/gb/crt0.s508+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/gbz80/gb/global.s508+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rgbdk-lib/libc/gb/sfr.s -> gbdk-lib/libc/targets/gbz80/gb/sfr.s0
Rgbdk-lib/libc/gb/gb_decompress.s -> gbdk-lib/libc/targets/gbz80/gb_decompress.s0
Rgbdk-lib/libc/gb/gb_decompress_tiles.s -> gbdk-lib/libc/targets/gbz80/gb_decompress_tiles.s0
Rgbdk-lib/libc/gb/get_addr.s -> gbdk-lib/libc/targets/gbz80/get_addr.s0
Rgbdk-lib/libc/gb/get_bk_t.s -> gbdk-lib/libc/targets/gbz80/get_bk_t.s0
Rgbdk-lib/libc/gb/get_data.s -> gbdk-lib/libc/targets/gbz80/get_data.s0
Rgbdk-lib/libc/gb/get_t.s -> gbdk-lib/libc/targets/gbz80/get_t.s0
Rgbdk-lib/libc/gb/get_tile.s -> gbdk-lib/libc/targets/gbz80/get_tile.s0
Rgbdk-lib/libc/gb/get_wi_t.s -> gbdk-lib/libc/targets/gbz80/get_wi_t.s0
Rgbdk-lib/libc/gb/get_xy_t.s -> gbdk-lib/libc/targets/gbz80/get_xy_t.s0
Rgbdk-lib/libc/gb/gprint.c -> gbdk-lib/libc/targets/gbz80/gprint.c0
Rgbdk-lib/libc/gb/gprintf.c -> gbdk-lib/libc/targets/gbz80/gprintf.c0
Rgbdk-lib/libc/gb/gprintln.c -> gbdk-lib/libc/targets/gbz80/gprintln.c0
Rgbdk-lib/libc/gb/gprintn.c -> gbdk-lib/libc/targets/gbz80/gprintn.c0
Rgbdk-lib/libc/gb/heap.s -> gbdk-lib/libc/targets/gbz80/heap.s0
Rgbdk-lib/libc/gb/hiramcpy.s -> gbdk-lib/libc/targets/gbz80/hiramcpy.s0
Rgbdk-lib/libc/gb/init_tt.s -> gbdk-lib/libc/targets/gbz80/init_tt.s0
Rgbdk-lib/libc/gb/init_vram.s -> gbdk-lib/libc/targets/gbz80/init_vram.s0
Agbdk-lib/libc/targets/gbz80/input.s647+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rgbdk-lib/libc/gb/joy.s -> gbdk-lib/libc/targets/gbz80/joy.s0
Rgbdk-lib/libc/gb/lcd.s -> gbdk-lib/libc/targets/gbz80/lcd.s0
Rgbdk-lib/libc/gb/metasprites.s -> gbdk-lib/libc/targets/gbz80/metasprites.s0
Rgbdk-lib/libc/gb/metasprites_flip.s -> gbdk-lib/libc/targets/gbz80/metasprites_flip.s0
Rgbdk-lib/libc/gb/metasprites_hide.s -> gbdk-lib/libc/targets/gbz80/metasprites_hide.s0
Rgbdk-lib/libc/gb/metasprites_hide_spr.s -> gbdk-lib/libc/targets/gbz80/metasprites_hide_spr.s0
Rgbdk-lib/libc/gb/mode.s -> gbdk-lib/libc/targets/gbz80/mode.s0
Rgbdk-lib/libc/gb/mv_spr.s -> gbdk-lib/libc/targets/gbz80/mv_spr.s0
Rgbdk-lib/libc/gb/nowait.s -> gbdk-lib/libc/targets/gbz80/nowait.s0
Rgbdk-lib/libc/gb/pad.s -> gbdk-lib/libc/targets/gbz80/pad.s0
Rgbdk-lib/libc/gb/pad_ex.s -> gbdk-lib/libc/targets/gbz80/pad_ex.s0
Rgbdk-lib/libc/gb/sample.s -> gbdk-lib/libc/targets/gbz80/sample.s0
Rgbdk-lib/libc/gb/serial.s -> gbdk-lib/libc/targets/gbz80/serial.s0
Rgbdk-lib/libc/gb/set_1bit_data.s -> gbdk-lib/libc/targets/gbz80/set_1bit_data.s0
Rgbdk-lib/libc/gb/set_bk_t.s -> gbdk-lib/libc/targets/gbz80/set_bk_t.s0
Rgbdk-lib/libc/gb/set_data.s -> gbdk-lib/libc/targets/gbz80/set_data.s0
Rgbdk-lib/libc/gb/set_prop.s -> gbdk-lib/libc/targets/gbz80/set_prop.s0
Rgbdk-lib/libc/gb/set_spr.s -> gbdk-lib/libc/targets/gbz80/set_spr.s0
Rgbdk-lib/libc/gb/set_t.s -> gbdk-lib/libc/targets/gbz80/set_t.s0
Rgbdk-lib/libc/gb/set_tile.s -> gbdk-lib/libc/targets/gbz80/set_tile.s0
Rgbdk-lib/libc/gb/set_tile_submap.s -> gbdk-lib/libc/targets/gbz80/set_tile_submap.s0
Rgbdk-lib/libc/gb/set_wi_t.s -> gbdk-lib/libc/targets/gbz80/set_wi_t.s0
Rgbdk-lib/libc/gb/set_win_tile_submap.s -> gbdk-lib/libc/targets/gbz80/set_win_tile_submap.s0
Rgbdk-lib/libc/gb/set_xy_t.s -> gbdk-lib/libc/targets/gbz80/set_xy_t.s0
Rgbdk-lib/libc/gb/sgb.s -> gbdk-lib/libc/targets/gbz80/sgb.s0
Rgbdk-lib/libc/gb/stubs.rasm -> gbdk-lib/libc/targets/gbz80/stubs.rasm0
Rgbdk-lib/libc/gb/stubs.s -> gbdk-lib/libc/targets/gbz80/stubs.s0
Rgbdk-lib/libc/gb/tim.s -> gbdk-lib/libc/targets/gbz80/tim.s0
Agbdk-lib/libc/targets/z80/__sdcc_bcall.s68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/crt0.s232+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/gg/Makefile25+++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/gg/global.s203+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/gg/nmi.s9+++++++++
Agbdk-lib/libc/targets/z80/gg/palette.s109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/int.s197+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/outi.s20++++++++++++++++++++
Agbdk-lib/libc/targets/z80/pad.s38++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/pad_ex.s64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/set_2bpp_data.s67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/set_data.s53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/set_tile_map.s25+++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/set_tile_map_compat.s25+++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/set_tile_map_xy.s83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/sms/Makefile25+++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/sms/global.s201+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/sms/nmi.s9+++++++++
Agbdk-lib/libc/targets/z80/sms/palette.s105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-lib/libc/targets/z80/vmemcpy.s41+++++++++++++++++++++++++++++++++++++++++
Mgbdk-support/bankpack/bankpack.c12+++++++++---
Mgbdk-support/bankpack/files.c5+++--
Mgbdk-support/bankpack/obj_data.c131++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------
Mgbdk-support/bankpack/obj_data.h17+++++++++++++++++
Mgbdk-support/lcc/Makefile2+-
Mgbdk-support/lcc/gb.c129++++++++++++++++++++++++++++++-------------------------------------------------
Mgbdk-support/lcc/gb.h5+++++
Mgbdk-support/lcc/lcc.c135+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Agbdk-support/lcc/targets.c100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agbdk-support/lcc/targets.h38++++++++++++++++++++++++++++++++++++++
325 files changed, 26963 insertions(+), 4981 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -75,3 +75,6 @@ make.bat # Doc generation files gbdk-lib/doc/ + +# VS.Code folder +.vscode diff --git a/Makefile b/Makefile @@ -10,6 +10,9 @@ PKG = gbdk # Version, used for tarballs VER = 3.00 +PORTS=gbz80 z80 +PLATFORMS=gb ap gg sms + # Prefix to add to the standard tools. Usefull for a standard gcc # cross-compile. TOOLSPREFIX = @@ -173,29 +176,58 @@ gbdk-support-clean: gbdk-lib-build: check-SDCCDIR ifndef CROSSCOMPILING @echo Building lib - @$(MAKE) -C $(GBDKLIBDIR)/libc PORTS=gbz80 PLATFORMS=gb --no-print-directory + @$(MAKE) -C $(GBDKLIBDIR)/libc PORTS="$(PORTS)" PLATFORMS="$(PLATFORMS)" --no-print-directory @echo endif + gbdk-lib-install: gbdk-lib-build +gbdk-lib-install: gbdk-lib-install-prepare +gbdk-lib-install: gbdk-lib-install-examples +gbdk-lib-install: gbdk-lib-install-ports +gbdk-lib-install: gbdk-lib-install-platforms + +gbdk-lib-install-prepare: + @rm -rf $(BUILDDIR)/lib + +gbdk-lib-install-ports: + @for port in $(PORTS); do \ + echo Installing lib for port: $$port; \ + mkdir -p $(BUILDDIR)/lib/small/asxxxx/$$port/; \ + cp $(GBDKLIBDIR)/build/small/asxxxx/$$port/$$port.lib $(BUILDDIR)/lib/small/asxxxx/$$port/$$port.lib; \ + done + @echo + +# The inner loop copies global.s for platforms from relevant port/platform. +# When doing that it expects a given platform to never be present in +# multiple ports since the copy destination is not port specific (lacks /$$port/ ) +gbdk-lib-install-platforms: + @for plat in $(PLATFORMS); do \ + echo Installing lib for platform: $$plat; \ + mkdir -p $(BUILDDIR)/lib/small/asxxxx/$$plat; \ + cp $(GBDKLIBDIR)/build/small/asxxxx/$$plat/crt0.o $(BUILDDIR)/lib/small/asxxxx/$$plat/crt0.o; \ + cp $(GBDKLIBDIR)/build/small/asxxxx/$$plat/$$plat.lib $(BUILDDIR)/lib/small/asxxxx/$$plat/$$plat.lib; \ + for port in $(PORTS); do \ + if [ -d "$(GBDKLIBDIR)/libc/targets/$$port/$$plat" ]; then \ + cp $(GBDKLIBDIR)/libc/targets/$$port/$$plat/global.s $(BUILDDIR)/lib/small/asxxxx/$$plat/global.s; \ + fi \ + done \ + done + @echo + + +gbdk-lib-install-examples: @echo Installing Examples @cp -r $(GBDKLIBDIR)/include $(GBDKLIBDIR)/examples $(BUILDDIR) - @echo - @echo Installing lib - @rm -rf $(BUILDDIR)/lib - mkdir -p $(BUILDDIR)/lib/small/asxxxx/gb/ - mkdir -p $(BUILDDIR)/lib/small/asxxxx/gbz80/ - @cp $(GBDKLIBDIR)/build/small/asxxxx/gb/crt0.o $(BUILDDIR)/lib/small/asxxxx/gb/crt0.o - @cp $(GBDKLIBDIR)/build/small/asxxxx/gb/gb.lib $(BUILDDIR)/lib/small/asxxxx/gb/gb.lib - @cp $(GBDKLIBDIR)/build/small/asxxxx/gbz80/gbz80.lib $(BUILDDIR)/lib/small/asxxxx/gbz80/gbz80.lib - @cp $(GBDKLIBDIR)/libc/gb/global.s $(BUILDDIR)/lib/small/asxxxx/global.s - @echo Generating make.bat + @echo Generating Examples make.bat @$(MAKE) -C $(BUILDDIR)/examples/gb make.bat --no-print-directory + @$(MAKE) -C $(BUILDDIR)/examples/ap make.bat --no-print-directory @echo + gbdk-lib-clean: @echo Cleaning lib - @$(MAKE) -C $(GBDKLIBDIR) clean + @$(MAKE) -C $(GBDKLIBDIR) PORTS="$(PORTS)" PLATFORMS="$(PLATFORMS)" clean @echo gbdk-lib-examples-makefile: @@ -210,7 +242,7 @@ gbdk-dist-examples-clean: # Copy SDDC executable files -SDCC_BINS = makebin packihx sdar sdasgb sdcc sdcdb sdcpp sdldgb sdnm sdobjcopy sdranlib sz80 +SDCC_BINS = makebin packihx sdar sdasgb sdcc sdcdb sdcpp sdldgb sdnm sdobjcopy sdranlib sz80 sdasz80 sdldz80 ifeq ($(OS),Windows_NT) MINGW64_RUNTIME = \ libgcc_s_seh-1.dll \ diff --git a/gbdk-lib/Makefile.common b/gbdk-lib/Makefile.common @@ -8,10 +8,10 @@ MODEL = small endif ifndef PORTS -PORTS = gbz80 +PORTS = gbz80 z80 endif ifndef PLATFORMS -PLATFORMS = gb +PLATFORMS = gb ap gg sms endif ifndef SDCCLIB @@ -32,7 +32,7 @@ endif CLEANSPEC = *.o *.cdb *.sym *.lst *~ *.asm -CFLAGS = -I$(TOPDIR)/include -DSDCC_z80 -D__gbz80 +CFLAGS = -I$(TOPDIR)/include -DSDCC_z80 -D__PORT_$(PORT) -D__TARGET_$(THIS) CFLAGS += -m$(PORT) -DGBDK=1 CFLAGS += --max-allocs-per-node 50000 CC = $(SCC) diff --git a/gbdk-lib/examples/ap/Makefile b/gbdk-lib/examples/ap/Makefile @@ -0,0 +1,17 @@ +# Register all subdirectories in the project's root directory. +SUBDIRS := $(wildcard */.) + +# Top-level phony targets. +all clean make.bat: $(SUBDIRS) FORCE +# Similar to: +# .PHONY: all clean +# all clean: $(SUBDIRS) +# GNU's .PHONY target is more efficient in that it explicitly declares non-files. + +# Recurse `make` into each subdirectory +# Pass along targets specified at command-line (if any). +$(SUBDIRS): FORCE + $(MAKE) -C $@ $(MAKECMDGOALS) + +# Force targets. +FORCE: + diff --git a/gbdk-lib/examples/ap/Makefile.rgbds b/gbdk-lib/examples/ap/Makefile.rgbds @@ -0,0 +1,92 @@ +TOPDIR= ../.. +CC= $(TOPDIR)/bin/sdcc -mgbz80 --asm=rgbds -I$(TOPDIR)/include -v +GBLIB = $(TOPDIR)/lib/rgbds +LIB = $(GBLIB)/gbz80/gbz80.lib $(GBLIB)/gb/gb.lib +CRT0 = $(GBLIB)/gb/crt0.o + +BINS = \ + galaxy.gb \ + paint.gb \ + rpn.gb \ + rand.gb \ + comm.gb \ + irq.gb \ + filltest.gb \ + fonts.gb \ + samptest.gb + +# sound.gb: Cant do bitfields +OTHER = sound.gb \ + banks.gb \ + ram_fn.gb + +all: $(BINS) + +make.bat: Makefile + make -sn | sed y/\\//\\\\/ | grep -v make > make.bat + +%.o: %.s + +%.asm: %.s + astorgb.pl $< > $@ + +%.o: %.c + $(CC) -c $< + +%.s: %.c + $(CC) -S $< + +%.o: %.asm + rgbasm -o$@ $< + +%.gb: %.o + $(CC) $(CRT0) $< $(LIB) + cp a.gb $@ + rgbfix -p -v $@ + +clean: + rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm + +############################################################ +# Multiple bank example + +# Compile bank 0 (no ROM) +# RAM bank 0 : -Wf-ba0 +# +bank_0.o: bank_0.c + $(CC) -Wf-ba0 -c -o $@ $< + +# Compile bank 1 (ROM+RAM) +# ROM bank 1 : -Wf-bo1 +# RAM bank 1 : -Wf-ba1 +# +bank_1.o: bank_1.c + $(CC) -Wf-bo1 -Wf-ba1 -c -o $@ $< + +# Compile bank 2 (ROM+RAM) +# ROM bank 2 : -Wf-bo2 +# RAM bank 2 : -Wf-ba2 +# +bank_2.o: bank_2.c + $(CC) -Wf-bo2 -Wf-ba2 -c -o $@ $< + +# Compile bank 3 (ROM+RAM) +# ROM bank 3 : -Wf-bo3 +# RAM bank 3 : -Wf-ba3 +# +bank_3.o: bank_3.c + $(CC) -Wf-bo3 -Wf-ba3 -c -o $@ $< + +# Link banks +# ROM+MBC1+RAM : -Wl-yt2 +# 4 ROM banks : -Wl-yo4 +# 4 RAM banks : -Wl-ya4 +# +banks.gb: banks.o bank_0.o bank_1.o bank_2.o bank_3.o + $(CC) -Wl-yt2 -Wl-yo4 -Wl-ya4 -o $@ banks.o bank_0.o bank_1.o bank_2.o bank_3.o + +############################################################ +# RAM function example + +ram_fn.gb: ram_fn.o + $(CC) -Wl-g_inc_ram=0xD000 -Wl-g_inc_hiram=0xFFA0 -o $@ ram_fn.o diff --git a/gbdk-lib/examples/ap/banks/Makefile b/gbdk-lib/examples/ap/banks/Makefile @@ -0,0 +1,63 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = banks.pocket \ + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +%.o: %.c + $(CC) -c -o $@ $< + +%.s: %.c + $(CC) -S -o $@ $< + +%.o: %.s + $(CC) -c -o $@ $< + +%.pocket: %.o + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + +############################################################ +# Multiple bank example + +# Compile bank 0 (no ROM) +# RAM bank 0 : -Wf-ba0 +# +bank_0.o: bank_0.c + $(CC) -Wf-ba0 -c -o $@ $< + +# Compile bank 1 (ROM+RAM) +# ROM bank 1 : -Wf-bo1 +# RAM bank 1 : -Wf-ba1 +# +bank_1.o: bank_1.c + $(CC) -Wf-bo1 -Wf-ba1 -c -o $@ $< + +# Compile bank 2 (ROM+RAM) +# ROM bank 2 : -Wf-bo2 +# RAM bank 2 : -Wf-ba2 +# +bank_2.o: bank_2.c + $(CC) -Wf-bo2 -Wf-ba2 -c -o $@ $< + +# Compile bank 3 (ROM+RAM) +# ROM bank 3 : -Wf-bo3 +# RAM bank 3 : -Wf-ba3 +# +bank_3.o: bank_3.c + $(CC) -Wf-bo3 -Wf-ba3 -c -o $@ $< + +# Link banks +# MBC5+ROM+RAM : -Wl-yt0x19 +# 4 ROM banks : -Wl-yo4 +# 4 RAM banks : -Wl-ya4 +# +banks.pocket: banks.o bank_0.o bank_1.o bank_2.o bank_3.o + $(CC) -Wl-yt0x1A -Wl-yo4 -Wl-ya4 -o $@ banks.o bank_0.o bank_1.o bank_2.o bank_3.o + diff --git a/gbdk-lib/examples/ap/banks/bank_0.c b/gbdk-lib/examples/ap/banks/bank_0.c @@ -0,0 +1,4 @@ +#include <gb/gb.h> +#include <stdint.h> + +int var_0; /* In external RAM bank 0 */ diff --git a/gbdk-lib/examples/ap/banks/bank_1.c b/gbdk-lib/examples/ap/banks/bank_1.c @@ -0,0 +1,10 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +int var_1; /* In external RAM bank 1 */ + +void bank_1() BANKED /* In ROM bank 1 */ +{ + puts("I'm in ROM bank 1"); +} diff --git a/gbdk-lib/examples/ap/banks/bank_2.c b/gbdk-lib/examples/ap/banks/bank_2.c @@ -0,0 +1,10 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +int var_2; /* In external RAM bank 2 */ + +void bank_2() BANKED /* In ROM bank 2 */ +{ + puts("I'm in ROM bank 2"); +} diff --git a/gbdk-lib/examples/ap/banks/bank_3.c b/gbdk-lib/examples/ap/banks/bank_3.c @@ -0,0 +1,10 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +int var_3; /* In external RAM bank 3 */ + +void bank_3() BANKED /* In ROM bank 3 */ +{ + puts("I'm in ROM bank 3"); +} diff --git a/gbdk-lib/examples/ap/banks/banks.c b/gbdk-lib/examples/ap/banks/banks.c @@ -0,0 +1,61 @@ +/** Note that this example is a bit old. Try BANKED and NONBANKED + as in banked/ + */ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +int var_internal; /* In internal RAM */ +extern int var_0; /* In external RAM bank 0 */ +extern int var_1; /* In external RAM bank 1 */ +extern int var_2; /* In external RAM bank 2 */ +extern int var_3; /* In external RAM bank 3 */ + +void bank_1() BANKED; +void bank_2() BANKED; +void bank_3() BANKED; + +void bank_fixed(void) NONBANKED +{ + puts("I'm in fixed ROM"); +} + +void print_var(uint8_t bank) +{ + SWITCH_RAM(bank); + printf("Var_%u is %u\n"); +} + +void main(void) +{ + puts("Program Start..."); + + ENABLE_RAM; + + var_internal = 1; + SWITCH_RAM(0); + var_0 = 2; + SWITCH_RAM(1); + var_1 = 3; + SWITCH_RAM(2); + var_2 = 4; + SWITCH_RAM(3); + var_3 = 5; + + bank_fixed(); + bank_1(); + bank_2(); + bank_3(); + + printf("Var is %u\n", var_internal); + SWITCH_RAM(0); + printf("Var_0 is %u\n", var_0); + SWITCH_RAM(1); + printf("Var_1 is %u\n", var_1); + SWITCH_RAM(2); + printf("Var_2 is %u\n", var_2); + SWITCH_RAM(3); + printf("Var_3 is %u\n", var_3); + + puts("The End..."); +} diff --git a/gbdk-lib/examples/ap/banks_autobank/Makefile b/gbdk-lib/examples/ap/banks_autobank/Makefile @@ -0,0 +1,70 @@ +LCC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS +BANKPACK = ../../../bin/bankpack + +# uncomment for lcc verbose output +# CFLAGS = -v + +BINS = autobanks.pocket +CSOURCES := $(wildcard *.c) +ASMSOURCES := $(wildcard *.s) + +# Compiling will produce .o files +OBJS = $(CSOURCES:%.c=%.o) $(ASMSOURCES:%.c=%.o) + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +%.o: %.c + $(LCC) $(CFLAGS) -c -o $@ $< + +%.o: %.s + $(LCC) $(CFLAGS) -c -o $@ $< + +%.s: %.c + $(LCC) $(CFLAGS) -S -o $@ $< + +# Process: .c and .s files -> .o -> (bankpack) -> .rel -> (linker) ... -> .pocket +# +# -autobank : Tells lcc to call bankpack for the compiled object (.o) files before linking +# -Wb-ext=.rel : Set output extension for autobanked files to .rel +# -Wb-v : Prints out assigned autobank info (optional) +# -Wl-yoA : Have makebin automatically calculate required number of ROM banks (otherwise use -Wl-yo4 in this example) +# -Wl-ya4 : Use 4 RAM banks +# -Wl-yt0x1B : Use MBC5+RAM+BATTERY cartridge type +$(BINS): $(OBJS) + $(LCC) $(CFLAGS) -autobank -Wb-ext=.rel -Wb-v -Wl-yt0x1B -Wl-yoA -Wl-ya4 -o $(BINS) $(OBJS) + + +# It's also possible to do all the compiling, autobanking and linking in a single call to lcc +# with none of the other makefile "targets" above. You can try this target out by using "make onepass". +# Notice that the input files are the .c and .asm sources instead of the compiled object files. +onepass: + $(LCC) $(CFLAGS) -autobank -Wb-ext=.rel -Wb-v -Wl-yt0x1B -Wl-yoA -Wl-ya4 -o $(BINS) $(CSOURCES) $(ASMSOURCES) + + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm *.rel *.sav + + +# For lcc linker option: -Wl-ytN where N is one of the numbers below +# +# ROM Byte 0147: Cartridge type +# +# 0-ROM ONLY 12-ROM+MBC3+RAM +# 1-ROM+MBC1 13-ROM+MBC3+RAM+BATT +# 2-ROM+MBC1+RAM 19-ROM+MBC5 +# 3-ROM+MBC1+RAM+BATT 1A-ROM+MBC5+RAM +# 5-ROM+MBC2 1B-ROM+MBC5+RAM+BATT +# 6-ROM+MBC2+BATTERY 1C-ROM+MBC5+RUMBLE +# 8-ROM+RAM 1D-ROM+MBC5+RUMBLE+SRAM +# 9-ROM+RAM+BATTERY 1E-ROM+MBC5+RUMBLE+SRAM+BATT +# B-ROM+MMM01 1F-Pocket Camera +# C-ROM+MMM01+SRAM FD-Bandai TAMA5 +# D-ROM+MMM01+SRAM+BATT FE - Hudson HuC-3 +# F-ROM+MBC3+TIMER+BATT FF - Hudson HuC-1 +# 10-ROM+MBC3+TIMER+RAM+BATT +# 11-ROM+MBC3 + diff --git a/gbdk-lib/examples/ap/banks_autobank/banks.c b/gbdk-lib/examples/ap/banks_autobank/banks.c @@ -0,0 +1,82 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +// Banked const vars from the other source files +// +// "BANKREF_EXTERN()" makes a "BANKREF()" reference +// from another source file accessible for use with "BANK()" +// +// The entries below could also be in separate, matching +// ".h" header files for each banked ".c" source file, +// instead of here at the start of "banks.c". +extern const uint8_t some_const_var_1; +BANKREF_EXTERN(some_const_var_1) + +extern const uint8_t some_const_var_2; +BANKREF_EXTERN(some_const_var_2) + +extern const uint8_t some_const_var_3; +BANKREF_EXTERN(some_const_var_3) + +extern const uint8_t some_const_var_4; +BANKREF_EXTERN(some_const_var_4) + +// Banked functions from the other source files +void func_1() BANKED; +BANKREF_EXTERN(func_1) + +void func_2() BANKED; +BANKREF_EXTERN(func_2) + +void func_3() BANKED; +BANKREF_EXTERN(func_3) + +void some_4() BANKED; +BANKREF_EXTERN(some_4) + +// Non-banked const +const uint8_t some_const_var_0 = 0; + +// Non-banked function +void bank_fixed(void) NONBANKED +{ + puts("I'm in fixed ROM"); +} + +void main(void) +{ + printf("Program Start...\n\n"); + + // Call the functions, unbanked first then the banked ones + bank_fixed(); + + + func_1(); + func_2(); + func_3(); + some_4(); + + printf("\n"); + + // Print the const vars, unbanked first then the banked ones + printf("Const0= %u nonbanked\n", some_const_var_0); + + SWITCH_ROM(BANK(some_const_var_1)); + printf("Const1= %u in bank %hu\n", some_const_var_1, BANK(some_const_var_1)); + SWITCH_ROM(BANK(some_const_var_2)); + printf("Const2= %u in bank %hu\n", some_const_var_2, BANK(some_const_var_2)); + SWITCH_ROM(BANK(some_const_var_3)); + printf("Const3= %u in bank %hu\n", some_const_var_3, BANK(some_const_var_3)); + SWITCH_ROM(BANK(some_const_var_4)); + printf("Const4= %u in bank %hu\n", some_const_var_4, BANK(some_const_var_4)); + + printf("\n"); + puts("The End..."); + + // Loop endlesslu + while(1) { + // Yield CPU till the end of each frame + wait_vbl_done(); + } +} diff --git a/gbdk-lib/examples/ap/banks_autobank/srcfile_1.c b/gbdk-lib/examples/ap/banks_autobank/srcfile_1.c @@ -0,0 +1,62 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +// These two entries are needed to enable auto-banking in the source file +#pragma bank 255 + + +BANKREF(some_const_var_1) +const uint8_t some_const_var_1 = 1; + + +BANKREF(func_1) +void func_1() BANKED +{ + printf("Func1 in ROM bank %u\n", _current_bank); +} + +// A big constant array to take up space +static const unsigned char local_const_1[] = { + + // 512 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + +}; diff --git a/gbdk-lib/examples/ap/banks_autobank/srcfile_2.c b/gbdk-lib/examples/ap/banks_autobank/srcfile_2.c @@ -0,0 +1,302 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +// These two entries are needed to enable auto-banking in the source file +#pragma bank 255 + + +BANKREF(some_const_var_2) +const uint8_t some_const_var_2 = 2; + + +BANKREF(func_2) +void func_2() BANKED +{ + printf("Func2 in ROM bank %u\n", _current_bank); +} + +// A big constant array to take up space +static const unsigned char local_const_2[] = { + + // 512 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1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1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +}; + diff --git a/gbdk-lib/examples/ap/banks_autobank/srcfile_3.c b/gbdk-lib/examples/ap/banks_autobank/srcfile_3.c @@ -0,0 +1,26 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +// These two entries are needed to enable auto-banking in the source file +#pragma bank 255 + +BANKREF(some_const_var_3) +const uint8_t some_const_var_3 = 3; + + +BANKREF(func_3) +void func_3() BANKED +{ + printf("Func3 in ROM bank %u\n", _current_bank); +} + +// A big constant array to take up space +static const unsigned char local_const_3[] = { + + // 256 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +}; diff --git a/gbdk-lib/examples/ap/banks_autobank/srcfile_4_not-autobanked.c b/gbdk-lib/examples/ap/banks_autobank/srcfile_4_not-autobanked.c @@ -0,0 +1,343 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +// In this source file a non-auto bank (2) is used (no auto-banking) +#pragma bank 2 + + +const uint8_t some_const_var_4 = 4; +BANKREF(some_const_var_4) + +void some_4() BANKED +{ + printf("Func4 not autobanked" + " is in ROM bank %u\n", _current_bank); +} +BANKREF(some_4) + +// A big constant array to take up space +static const unsigned char local_const_4[] = { + + // 512 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,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efile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +%.o: %.c + $(CC) -c -o $@ $< + +%.s: %.c + $(CC) -S -o $@ $< + +%.o: %.s + $(CC) -c -o $@ $< + +%.pocket: %.o + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + +############################################################ +# Banks using Far pointers example + +bank2code.o: bank2code.c + $(CC) -c -o $@ $< + +banks_farptr.pocket: banks_farptr.o bank2code.o + $(CC) -Wl-yt0x19 -Wl-yoA -o $@ bank2code.o banks_farptr.o + diff --git a/gbdk-lib/examples/ap/banks_farptr/bank2code.c b/gbdk-lib/examples/ap/banks_farptr/bank2code.c @@ -0,0 +1,21 @@ +#pragma bank 2 + +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +static int local_bank2_proc(int param1, int param2) { + printf(" sum: %d (bank=%d)\n", param1 + param2, (int)_current_bank); + return (param1 + param2) << 1; +} + +BANKREF(some_bank2_proc0) +void some_bank2_proc0() __banked { + printf("some_bank2_proc0\n"); +} + +BANKREF(some_bank2_proc1) +int some_bank2_proc1(int param1, int param2) __banked { + printf("some_bank2_proc1\n"); + return local_bank2_proc(param1, param2); +} diff --git a/gbdk-lib/examples/ap/banks_farptr/banks_farptr.c b/gbdk-lib/examples/ap/banks_farptr/banks_farptr.c @@ -0,0 +1,49 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <gb/far_ptr.h> + +#include <stdio.h> + +// functions from bank2code.c +BANKREF_EXTERN(some_bank2_proc0) +extern void some_bank2_proc0() __banked; + +BANKREF_EXTERN(some_bank2_proc1) +extern int some_bank2_proc1(int param1, int param2) __banked; +typedef int (*some_bank2_proc_t)(int, int) __banked; // define type for some_bank2_proc1() function + +// far pointers +FAR_PTR farptr_var0, farptr_var1, farptr_var2; + +// result of a function call +int res; + +void run() { + // compose far pointer at runtime + farptr_var0 = to_far_ptr(some_bank2_proc1, BANK(some_bank2_proc1)); + farptr_var1 = to_far_ptr(some_bank2_proc1, BANK(some_bank2_proc1)); + farptr_var2 = to_far_ptr(some_bank2_proc0, BANK(some_bank2_proc0)); + + // output far pointers (must be identical) + printf("FAR PTR0: %x:%x\n", (int)FAR_SEG(farptr_var0), (int)FAR_OFS(farptr_var0)); + printf("FAR PTR1: %x:%x\n", (int)FAR_SEG(farptr_var1), (int)FAR_OFS(farptr_var1)); + + // try calling far function by far pointer without params + FAR_CALL(farptr_var2, void (*)(void)); + + // try calling far function directly + res = some_bank2_proc1(100, 50); + printf("CALL DIR: %d\n", res); + + // try calling far function by far pointer + res = FAR_CALL(farptr_var1, some_bank2_proc_t, 100, 50); + + printf("CALL IND: %d\n", res); +} + +void main() { + ENABLE_RAM_MBC1; + printf("START (bank=%d)\n", (int)_current_bank); + run(); + printf("DONE! (bank=%d)\n", (int)_current_bank); +} + diff --git a/gbdk-lib/examples/ap/banks_nonintrinsic/Makefile b/gbdk-lib/examples/ap/banks_nonintrinsic/Makefile @@ -0,0 +1,26 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = banks_nonintrinsic.pocket + + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +%.o: %.c + $(CC) -c -o $@ $< + +%.s: %.c + $(CC) -S -o $@ $< + +%.o: %.s + $(CC) -c -o $@ $< + +%.pocket: %.o + $(CC) -Wl-yt0x1A -Wl-yoA -Wl-ya4 -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/banks_nonintrinsic/banks_nonintrinsic.c b/gbdk-lib/examples/ap/banks_nonintrinsic/banks_nonintrinsic.c @@ -0,0 +1,90 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +// force bank switching macro +uint8_t __dummy_variable; +#define switch_to(x) (__dummy_variable = (char)((x)[0]), (void *)(x)) + +uint8_t _current_ram_bank = 0; +#define SWITCH_RAM_BANK(x) (_current_ram_bank = (SWITCH_RAM_MBC1(x), x)) + +// constant in base ROM +const char const hello0[] = "hello from CODE\n"; +// variable in base RAM +char data[20] = "DATA"; +int addendum0 = 1; + +// constants in ROM banks + +void set_ROM_bank1(void) NONBANKED __preserves_regs(b, c, d, e) { SWITCH_ROM_MBC1(1); } +void set_ROM_bank2(void) NONBANKED __preserves_regs(b, c, d, e) { SWITCH_ROM_MBC1(2); } + +__addressmod set_ROM_bank1 const CODE_1; +__addressmod set_ROM_bank2 const CODE_2; + +CODE_1 const char hello1[] = "hello from CODE_1\n"; +CODE_2 const char hello2[] = "hello from CODE_2\n"; + +// variables in RAM banks + +void set_RAM_bank1(void) NONBANKED __preserves_regs(b, c, d, e) { SWITCH_RAM_BANK(1); } +void set_RAM_bank2(void) NONBANKED __preserves_regs(b, c, d, e) { SWITCH_RAM_BANK(2); } + +__addressmod set_RAM_bank1 DATA_1; +__addressmod set_RAM_bank2 DATA_2; + +DATA_1 char hello1_ram[20]; +DATA_1 int addendum1_ram; +DATA_2 char hello2_ram[20]; +DATA_2 int addendum2_ram; +DATA_2 int addendum3_ram; + +// define array of pointers in RAM2 to the variables that are RAM2 +// there is a flaw in compiler that disallows pointers into banks to be in the other banks +// details: https://sourceforge.net/p/sdcc/bugs/2995/ +DATA_2 int * const CODE_1 addendum_ptr[2] = {&addendum2_ram, &addendum3_ram}; + +void main() { + ENABLE_RAM_MBC5; + + addendum1_ram = 2; + addendum2_ram = 4; + addendum3_ram = 8; + + // say hello + for (int8_t i = 0; (hello0[i]); i++) putchar(hello0[i]); + for (int8_t i = 0; (hello1[i]); i++) putchar(hello1[i]); + for (int8_t i = 0; (hello2[i]); i++) putchar(hello2[i]); + + // prepare and say hello from rom bank1 to ram bank0 + for (int8_t i = 0; (i < sizeof(hello1)); i++) hello1_ram[i] = hello1[i]; + for (int8_t i = 0; (i < 4); i++) hello1_ram[i + 11] = data[i]; + for (int8_t i = 0; (hello1_ram[i]); i++) putchar(hello1_ram[i]); + + // prepare and say hello from rom bank1 to ram bank1 + for (int8_t i = 0; (i < sizeof(hello2)); i++) hello2_ram[i] = hello2[i]; + for (int8_t i = 0; (i < 4); i++) hello2_ram[i + 11] = data[i]; + for (int8_t i = 0; (hello2_ram[i]); i++) putchar(hello2_ram[i]); + + printf("once more...\n"); + // hello again; if we access we just access, don't care + for (int8_t i = 0; (hello0[i]); i++) putchar(hello0[i]); + for (int8_t i = 0; (hello1[i]); i++) putchar(hello1[i]); + for (int8_t i = 0; (hello2[i]); i++) putchar(hello2[i]); + for (int8_t i = 0; (hello1_ram[i]); i++) putchar(hello1_ram[i]); + for (int8_t i = 0; (hello2_ram[i]); i++) putchar(hello2_ram[i]); + + printf("once more...\n"); + // if we need an address, then we use a macro switch_to() + printf("%s", hello0); + printf("%s", switch_to(hello1)); + printf("%s", switch_to(hello2)); + printf("%s", switch_to(hello1_ram)); + printf("%s", switch_to(hello2_ram)); + + printf("1+2+4+8=0x%x", (int)(addendum0 + addendum1_ram + (*addendum_ptr[0]) + (*addendum_ptr[1]))); + + // stop + while(1); +} diff --git a/gbdk-lib/examples/ap/bcd/Makefile b/gbdk-lib/examples/ap/bcd/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = bcd.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/bcd/bcd.c b/gbdk-lib/examples/ap/bcd/bcd.c @@ -0,0 +1,37 @@ +#include <gb/gb.h> +#include <stdint.h> + +#include <stdio.h> +#include <gb/font.h> + +#include "bcd.h" + +BCD bcd = MAKE_BCD(10203040); +BCD bcd2 = MAKE_BCD(05060708); +BCD bcd3 = MAKE_BCD(11111111); + +uint8_t len = 0; +unsigned char buf[10]; + +void main() { + font_init(); + font_set(font_load(font_spect)); + + len = bcd2text(&bcd, 0x10, buf); + set_bkg_tiles(5, 5, len, 1, buf); + + bcd_add(&bcd, &bcd2); + + len = bcd2text(&bcd, 0x10, buf); + set_bkg_tiles(5, 6, len, 1, buf); + + bcd_sub(&bcd, &bcd3); + + len = bcd2text(&bcd, 0x10, buf); + set_bkg_tiles(5, 7, len, 1, buf); + + uint2bcd(12345, &bcd); + + len = bcd2text(&bcd, 0x10, buf); + set_bkg_tiles(5, 8, len, 1, buf); +} + diff --git a/gbdk-lib/examples/ap/bgb_debug/Makefile b/gbdk-lib/examples/ap/bgb_debug/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS -Wm-yc + +BINS = bgb_debug.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/bgb_debug/bgb_debug.c b/gbdk-lib/examples/ap/bgb_debug/bgb_debug.c @@ -0,0 +1,147 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> // Just for printf() +#include <gb/cgb.h> // Just for the cpu_fast()/slow() calls in CGB 2x example + +#include <gb/bgb_emu.h> // Use this include to add the BGB functions + + +// This example shows how to use support for profiling +// and logging to the debug window in the BGB emulator. +// +// 1. Build this ROM (bgb_debug.gb) then load it in the BGB emulator +// 2. Open the internal BGB debugger by pressing the "ESC" key +// 3. From the debugger menu choose "debug messages" to open the debug messages window +// 4. Reset the gameboy (you may need to press F9 in the debugger to resume running) +// 5. The debug window will show the BGB messages +// +// See the BGB Manual for more information +// ("expressions, breakpoint conditions, and debug messages") +// https://bgb.bircd.org/manual.html#expressions + +int main(void) +{ + int c; + + SHOW_BKG; + DISPLAY_ON; + enable_interrupts(); + + // Display a message on the GameBoy's screen + printf("Message to the \nGameBoy screen\n"); + + // Log a message to the BGB debug message window + BGB_MESSAGE(""); // new line + BGB_MESSAGE("Message to the BGB console"); + + // ==== Normal Speed Mode ==== + // Profile code: a single NOP instruction + // + // In BGB the clock units are "1 nop in [CGB] doublespeed mode". + // So when *not* running in CGB doublespeed mode you + // have to divide by 2 to get the correct cycle count. + // + // You should see the message "NOP TIME: 2". + // + // So in this case, divide the printed value by 2 = The NOP took "1" cycle + + __critical { // Temporarily turn off interrupts for more accurate measurements + BGB_PROFILE_BEGIN("Profile a single NOP instruction at Normal Speed"); + __asm__("nop"); + BGB_PROFILE_END("NOP TIME:"); + } + + + // ==== Color Game Boy in Double Speed Mode ==== + // Profile code: a single NOP instruction + // + // The BGB_PROFILE_BEGIN/END macros don't support the + // Color Game Boy (CGB) in double speed mode (cpu_fast()). + // The example below shows what to use instead (and how to + // check for a CGB and turn on Double Speed mode). + // + // Check and only run this test if on CGB hardware + if (_cpu == CGB_TYPE) { + + // Set CGB into double speed mode + // (Requires passing -Wm-yc or -Wm-yC with Lcc during build time) + cpu_fast(); + // Set some default DMG styled colors in the CGB Palette + cgb_compatibility(); + + // In CGB Double Speed mode, you don't have to + // divide by 2 to get the cycle count. + // + // You should see the message "NOP TIME: 1". + + __critical { // Temporarily turn off interrupts for more accurate measurements + BGB_PROFILE_BEGIN("Profile a single NOP instruction at CGB Double Speed"); + __asm__("nop"); + // The "-4+" subtracts 4 clocks to compensate for the ones + // used by the debug message itself (Normal speed uses -8) + BGB_MESSAGE("NOP TIME:%-4+LASTCLKS%"); + } + + // Return the CGB to normal speed + cpu_slow(); + } + + + __critical { // Temporarily turn off interrupts for more accurate measurements + + // Profile code in a loop + BGB_PROFILE_BEGIN("Profile code in a loop"); + for(c=0; c<5; c++) { + // Do something + printf("%d\n", c); + } + // Elapsed cycle count output is in hex. + // Remember to divide by 2 for the result (Normal Speed) + BGB_PROFILE_END("LOOP TIME:"); + } + + + // ==== Some other things you can print ==== + + // TOTALCLKS shows the clocks counter ("internal divider") in the BGB IO map + BGB_MESSAGE("Total Clocks: %TOTALCLKS%"); + + // CLKS2VBLANK + BGB_MESSAGE("Clocks until VBLANK: %CLKS2VBLANK%"); + + // Which Banks are currently active (for MBC based cartridges) + BGB_MESSAGE("Current ROM bank: %ROMBANK%"); + BGB_MESSAGE("Current SRAM bank: %SRAMBANK%"); + // These are only banked in the CGB + BGB_MESSAGE("Current VRAM bank: %VRAMBANK%"); + BGB_MESSAGE("Current WRAM bank: %WRAMBANK%"); + + // Registers (All in this case, or individual ones) + BGB_MESSAGE("All Registers: %ALLREGS%"); + + // Simple addition with a register + BGB_MESSAGE("Register A + 1: %(A+1)%"); + + // Read the LY Register a couple times + // (Current Y coordinate being rendered to the LCD) + BGB_MESSAGE("LY Register (0xFF44): %($ff44)%"); + BGB_MESSAGE("LY Register (0xFF44): %($ff44)%"); + // Now print a conditional debug message using it + BGB_MESSAGE("Is LY Register > Line 67: %($ff44)>67%Yes;No;"); + + // Print some profile info using a built-in function. + BGB_MESSAGE("The following lines contain: PROFILE,(SP+$0),(SP+$1),A,TOTALCLKS,ROMBANK,WRAMBANK"); + BGB_profiler_message(); + // It's equivalent to: + BGB_MESSAGE("PROFILE,%(SP+$0)%,%(SP+$1)%,%A%,%TOTALCLKS%,%ROMBANK%,%WRAMBANK%"); + + uint8_t var0 = 16; + int16_t var1 = -10; + // + BGB_printf("var0: %hd; var1: %d; var0*var1=%d", (uint8_t)var0, var1, var0 * var1); + + // The BGB_TEXT() macro will accept a non-quoted string + BGB_TEXT("The End"); + + return 0; +} diff --git a/gbdk-lib/examples/ap/colorbar/Makefile b/gbdk-lib/examples/ap/colorbar/Makefile @@ -0,0 +1,30 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +# CFLAGS = + +BINS = colorbar.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +%.o: %.s + $(CC) $(CFLAGS) -c -o $@ $< + +%.s: %.c + $(CC) $(CFLAGS) -S -o $@ $< + +%.pocket: %.o + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm + +# Link file, and write 0x80 at position 0x143 in header +colorbar.pocket: colorbar.o + $(CC) $(CFLAGS) -Wm-yC -o colorbar.pocket colorbar.o diff --git a/gbdk-lib/examples/ap/colorbar/bar_c.c b/gbdk-lib/examples/ap/colorbar/bar_c.c @@ -0,0 +1,102 @@ +/* + + BAR_C.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 31 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : 1 Byte per entry. + + Convert to metatiles : No. + + This file was generated by GBTD v1.6 + +*/ + +/* CGBpalette entries. */ +const unsigned char bar_cCGB[] = +{ + 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01, + 0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03, + 0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05, + 0x06,0x06,0x06,0x06,0x07,0x07,0x07,0x07 +}; +/* Start of tile array. */ +const unsigned char bar_c[] = +{ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF +}; + +/* End of BAR_C.C */ diff --git a/gbdk-lib/examples/ap/colorbar/bar_c.gbr b/gbdk-lib/examples/ap/colorbar/bar_c.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/colorbar/bar_c.h b/gbdk-lib/examples/ap/colorbar/bar_c.h @@ -0,0 +1,105 @@ +/* + + BAR_C.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 31 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : 1 Byte per entry. + + Convert to metatiles : No. + + This file was generated by GBTD v1.6 + +*/ + + +/* Bank of tiles. */ +#define bar_cBank 0 + +/* Super Gameboy palette 0 */ +#define bar_cSGBPal0c0 0 +#define bar_cSGBPal0c1 0 +#define bar_cSGBPal0c2 0 +#define bar_cSGBPal0c3 0 + +/* Super Gameboy palette 1 */ +#define bar_cSGBPal1c0 25368 +#define bar_cSGBPal1c1 0 +#define bar_cSGBPal1c2 4104 +#define bar_cSGBPal1c3 6 + +/* Super Gameboy palette 2 */ +#define bar_cSGBPal2c0 0 +#define bar_cSGBPal2c1 0 +#define bar_cSGBPal2c2 4104 +#define bar_cSGBPal2c3 6 + +/* Super Gameboy palette 3 */ +#define bar_cSGBPal3c0 0 +#define bar_cSGBPal3c1 0 +#define bar_cSGBPal3c2 4104 +#define bar_cSGBPal3c3 6 + +/* Gameboy Color palette 0 */ +#define bar_cCGBPal0c0 32767 +#define bar_cCGBPal0c1 25368 +#define bar_cCGBPal0c2 19026 +#define bar_cCGBPal0c3 0 + +/* Gameboy Color palette 1 */ +#define bar_cCGBPal1c0 18 +#define bar_cCGBPal1c1 24 +#define bar_cCGBPal1c2 31 +#define bar_cCGBPal1c3 12 + +/* Gameboy Color palette 2 */ +#define bar_cCGBPal2c0 384 +#define bar_cCGBPal2c1 576 +#define bar_cCGBPal2c2 768 +#define bar_cCGBPal2c3 992 + +/* Gameboy Color palette 3 */ +#define bar_cCGBPal3c0 12288 +#define bar_cCGBPal3c1 18432 +#define bar_cCGBPal3c2 24576 +#define bar_cCGBPal3c3 31744 + +/* Gameboy Color palette 4 */ +#define bar_cCGBPal4c0 792 +#define bar_cCGBPal4c1 1023 +#define bar_cCGBPal4c2 396 +#define bar_cCGBPal4c3 594 + +/* Gameboy Color palette 5 */ +#define bar_cCGBPal5c0 24600 +#define bar_cCGBPal5c1 31775 +#define bar_cCGBPal5c2 12300 +#define bar_cCGBPal5c3 18450 + +/* Gameboy Color palette 6 */ +#define bar_cCGBPal6c0 19008 +#define bar_cCGBPal6c1 25344 +#define bar_cCGBPal6c2 32736 +#define bar_cCGBPal6c3 12672 + +/* Gameboy Color palette 7 */ +#define bar_cCGBPal7c0 32767 +#define bar_cCGBPal7c1 25368 +#define bar_cCGBPal7c2 19026 +#define bar_cCGBPal7c3 12684 +/* CGBpalette entries. */ +extern const unsigned char bar_cCGB[]; +/* Start of tile array. */ +extern const unsigned char bar_c[]; + +/* End of BAR_C.H */ diff --git a/gbdk-lib/examples/ap/colorbar/bar_m.c b/gbdk-lib/examples/ap/colorbar/bar_m.c @@ -0,0 +1,62 @@ +/* + + BAR_M.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 20 x 18 + Tile set : C:\SDK\gb-gb\tmp\bar_c.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + + This file was generated by GBMB v0.8 + +*/ + +#define bar_mWidth 20 +#define bar_mHeight 18 + +const unsigned char bar_m[] = +{ + 0x1F,0x1F,0x12,0x12,0x12,0x1B,0x1B,0x1B,0x08,0x08, + 0x08,0x16,0x16,0x16,0x07,0x07,0x07,0x0C,0x0C,0x0C, + 0x1E,0x1E,0x13,0x13,0x13,0x18,0x18,0x18,0x09,0x09, + 0x09,0x17,0x17,0x17,0x04,0x04,0x04,0x0D,0x0D,0x0D, + 0x1D,0x1D,0x10,0x10,0x10,0x19,0x19,0x19,0x0A,0x0A, + 0x0A,0x14,0x14,0x14,0x05,0x05,0x05,0x0E,0x0E,0x0E, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B, + 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F, + 0x0F,0x0F,0x03,0x03,0x03,0x15,0x15,0x15,0x03,0x03, + 0x03,0x1A,0x1A,0x1A,0x03,0x03,0x03,0x1C,0x1C,0x1C, + 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16, + 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16, + 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16, + 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, +}; + +/* End of BAR_M.C */ diff --git a/gbdk-lib/examples/ap/colorbar/bar_m.gbm b/gbdk-lib/examples/ap/colorbar/bar_m.gbm Binary files differ. diff --git a/gbdk-lib/examples/ap/colorbar/bar_m.h b/gbdk-lib/examples/ap/colorbar/bar_m.h @@ -0,0 +1,24 @@ +/* + + BAR_M.H + + Map Include File. + + Info: + Section : + Bank : 0 + Map size : 20 x 18 + Tile set : C:\SDK\gb-gb\tmp\bar_c.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + + This file was generated by GBMB v0.8 + +*/ + +#define bar_mWidth 20 +#define bar_mHeight 18 + +extern const unsigned char bar_m[]; + +/* End of BAR_M.H */ diff --git a/gbdk-lib/examples/ap/colorbar/colorbar.c b/gbdk-lib/examples/ap/colorbar/colorbar.c @@ -0,0 +1,73 @@ +#include <gb/gb.h> +#include <gb/cgb.h> +#include <stdint.h> + +#include "bar_c.h" +#include "bar_c.c" +#include "bar_m.c" + +const uint16_t bar_p[] = +{ + bar_cCGBPal0c0,bar_cCGBPal0c1,bar_cCGBPal0c2,bar_cCGBPal0c3, + bar_cCGBPal1c0,bar_cCGBPal1c1,bar_cCGBPal1c2,bar_cCGBPal1c3, + bar_cCGBPal2c0,bar_cCGBPal2c1,bar_cCGBPal2c2,bar_cCGBPal2c3, + bar_cCGBPal3c0,bar_cCGBPal3c1,bar_cCGBPal3c2,bar_cCGBPal3c3, + bar_cCGBPal4c0,bar_cCGBPal4c1,bar_cCGBPal4c2,bar_cCGBPal4c3, + bar_cCGBPal5c0,bar_cCGBPal5c1,bar_cCGBPal5c2,bar_cCGBPal5c3, + bar_cCGBPal6c0,bar_cCGBPal6c1,bar_cCGBPal6c2,bar_cCGBPal6c3, + bar_cCGBPal7c0,bar_cCGBPal7c1,bar_cCGBPal7c2,bar_cCGBPal7c3 +}; + +const unsigned char bar_a[] = +{ + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3, + 3,3,0,0,0,5,5,5,0,0,0,6,6,6,0,0,0,7,7,7, + 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0, + 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0, + 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0 +}; + +int main(void) +{ + /* Transfer color palettes */ + set_bkg_palette( 7, 1, &bar_p[0] ); + set_bkg_palette( 6, 1, &bar_p[4] ); + set_bkg_palette( 5, 1, &bar_p[8] ); + set_bkg_palette( 4, 1, &bar_p[12] ); + set_bkg_palette( 3, 1, &bar_p[16] ); + set_bkg_palette( 2, 1, &bar_p[20] ); + set_bkg_palette( 1, 1, &bar_p[24] ); + set_bkg_palette( 0, 1, &bar_p[28] ); + + /* CHR code transfer */ + set_bkg_data( 0x0, 32, bar_c ); + + /* Select VRAM bank 1 */ + VBK_REG = 1; + /* Set attributes */ + set_bkg_tiles( 0, 0, bar_mWidth, bar_mHeight, bar_a ); + + /* Select VRAM bank 0 */ + VBK_REG = 0; + /* Set data */ + set_bkg_tiles( 0, 0, bar_mWidth, bar_mHeight, bar_m ); + + SHOW_BKG; + enable_interrupts(); + DISPLAY_ON; + + return 0; +} diff --git a/gbdk-lib/examples/ap/comm/Makefile b/gbdk-lib/examples/ap/comm/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = comm.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/comm/comm.c b/gbdk-lib/examples/ap/comm/comm.c @@ -0,0 +1,90 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +unsigned char str[] = "Hello World!"; +unsigned char buffer[32]; + +void main(void) +{ + uint8_t i, n = 0; + unsigned char *s; + + puts("Byte"); + puts(" A : Send"); + puts(" B : Receive"); + puts("String"); + puts(" START : Send"); + puts(" SELECT : Receive"); + + CRITICAL { + add_SIO(nowait_int_handler); // disable waiting VRAM state before return + set_interrupts(SIO_IFLAG); // disable other interrupts + } + + while(1) { + i = waitpad(J_A | J_B | J_START | J_SELECT); + waitpadup(); + + if (i == J_A) { + /* Send 1 byte */ + printf("Sending b... "); + _io_out = n++; + send_byte(); + /* Wait for IO completion... */ + while((_io_status == IO_SENDING) && (joypad() == 0)); + if(_io_status == IO_IDLE) + printf("OK\n"); + else + printf("#%d\n", _io_status); + } else if (i == J_B) { + /* Receive 1 byte */ + printf("Receiving b... "); + receive_byte(); + /* Wait for IO completion... */ + while((_io_status == IO_RECEIVING) && (joypad() == 0)); + if(_io_status == IO_IDLE) + printf("OK\n%d\n", _io_in); + else + printf("#%d\n", _io_status); + } else if (i == J_START) { + /* Send a string */ + printf("Sending s... "); + s = str; + while(1) { + _io_out = *s; + do { + send_byte(); + /* Wait for IO completion... */ + while((_io_status == IO_SENDING) && (joypad() == 0)); + } while((_io_status != IO_IDLE) && (joypad() == 0)); + if(_io_status != IO_IDLE) { + printf("#%d\n", _io_status); + break; + } + if(*s == 0) break; + s++; + } + if(_io_status == IO_IDLE) printf("OK\n"); + } else if (i == J_SELECT) { + /* Receive a string */ + printf("Receiving s... "); + s = buffer; + while(1) { + receive_byte(); + /* Wait for IO completion... */ + while((_io_status == IO_RECEIVING) && (joypad() == 0)); + if(_io_status != IO_IDLE) { + printf("#%d\n", _io_status); + break; + } + *s = _io_in; + if(*s == 0) break; + s++; + } + if(_io_status == IO_IDLE) printf("OK\n%s\n", buffer); + } + /* In case of user cancellation */ + waitpadup(); + } +} diff --git a/gbdk-lib/examples/ap/crash/Makefile b/gbdk-lib/examples/ap/crash/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = crash.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/crash/crash.c b/gbdk-lib/examples/ap/crash/crash.c @@ -0,0 +1,7 @@ +#include <gb/crash_handler.h> + +typedef void (*somefunc_t)(void); + +void main() { + ((somefunc_t)0x3000)(); // call something in the middle of nowhere +} + diff --git a/gbdk-lib/examples/ap/dscan/Makefile b/gbdk-lib/examples/ap/dscan/Makefile @@ -0,0 +1,24 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wm-yc -Wl-j -Wm-yS + +BINS = dscan.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +%.o: %.c + $(CC) -c -o $@ $< + +%.s: %.c + $(CC) -S -o $@ $< + +%.o: %.s + $(CC) -c -o $@ $< + +%.pocket: %.o + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm diff --git a/gbdk-lib/examples/ap/dscan/bkg.c b/gbdk-lib/examples/ap/dscan/bkg.c @@ -0,0 +1,238 @@ +/* + + BKG.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 95 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : 1 Byte per entry. + + Convert to metatiles : No. + + This file was generated by GBTD v1.6 + +*/ + +/* CGBpalette entries. */ +const unsigned char bkgCGB[] = +{ + 0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04, + 0x01,0x02,0x03,0x04,0x01,0x02,0x03,0x04, + 0x05,0x06,0x05,0x06,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; +/* Start of tile array. */ +const unsigned char bkg[] = +{ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, + 0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00, + 0x6C,0x6C,0x24,0x24,0x48,0x48,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x44,0x44,0xFE,0xFE,0x44,0x44,0x44,0x44, + 0x44,0x44,0xFE,0xFE,0x44,0x44,0x00,0x00, + 0x28,0x28,0x7E,0x7E,0xA8,0xA8,0x7C,0x7C, + 0x2A,0x2A,0xFC,0xFC,0x28,0x28,0x00,0x00, + 0x40,0x40,0xA4,0xA4,0x48,0x48,0x10,0x10, + 0x24,0x24,0x4A,0x4A,0x04,0x04,0x00,0x00, + 0x70,0x70,0x88,0x88,0x50,0x50,0x64,0x64, + 0x94,0x94,0x88,0x88,0x76,0x76,0x00,0x00, + 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x20, + 0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00, + 0x20,0x20,0x10,0x10,0x08,0x08,0x08,0x08, + 0x08,0x08,0x10,0x10,0x20,0x20,0x00,0x00, + 0x10,0x10,0x54,0x54,0x38,0x38,0x10,0x10, + 0x38,0x38,0x54,0x54,0x10,0x10,0x00,0x00, + 0x00,0x00,0x10,0x10,0x10,0x10,0x7C,0x7C, + 0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x7C, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00, + 0x00,0x00,0x04,0x04,0x08,0x08,0x10,0x10, + 0x20,0x20,0x40,0x40,0x00,0x00,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82, + 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0x10,0x10,0x30,0x30,0x10,0x10,0x10,0x10, + 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x82,0x82,0x0C,0x0C, + 0x30,0x30,0xC0,0xC0,0xFE,0xFE,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x02,0x02,0x1C,0x1C, + 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0x0C,0x0C,0x14,0x14,0x24,0x24,0x44,0x44, + 0x84,0x84,0xFE,0xFE,0x04,0x04,0x00,0x00, + 0xFE,0xFE,0x80,0x80,0xFC,0xFC,0x02,0x02, + 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x80,0x80,0xFC,0xFC, + 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0xFE,0xFE,0x82,0x82,0x04,0x04,0x08,0x08, + 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x82,0x82,0x7C,0x7C, + 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x82,0x82,0x7E,0x7E, + 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00, + 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00, + 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00, + 0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40, + 0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00, + 0x00,0x00,0x00,0x00,0x7C,0x7C,0x00,0x00, + 0x7C,0x7C,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08, + 0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x82,0x82,0x0C,0x0C, + 0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0xBA,0xBA,0xAA,0xAA, + 0xBE,0xBE,0x80,0x80,0x7E,0x7E,0x00,0x00, + 0x38,0x38,0x44,0x44,0x82,0x82,0x82,0x82, + 0xFE,0xFE,0x82,0x82,0x82,0x82,0x00,0x00, + 0xFC,0xFC,0x82,0x82,0x82,0x82,0xFC,0xFC, + 0x82,0x82,0x82,0x82,0xFC,0xFC,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x80,0x80,0x80,0x80, + 0x80,0x80,0x42,0x42,0x3C,0x3C,0x00,0x00, + 0xF8,0xF8,0x84,0x84,0x82,0x82,0x82,0x82, + 0x82,0x82,0x84,0x84,0xF8,0xF8,0x00,0x00, + 0xFE,0xFE,0x80,0x80,0x80,0x80,0xFC,0xFC, + 0x80,0x80,0x80,0x80,0xFE,0xFE,0x00,0x00, + 0xFE,0xFE,0x80,0x80,0x80,0x80,0xFC,0xFC, + 0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x80,0x80,0x80,0x80, + 0x8E,0x8E,0x42,0x42,0x3E,0x3E,0x00,0x00, + 0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0xFE, + 0x82,0x82,0x82,0x82,0x82,0x82,0x00,0x00, + 0x38,0x38,0x10,0x10,0x10,0x10,0x10,0x10, + 0x10,0x10,0x10,0x10,0x38,0x38,0x00,0x00, + 0x3C,0x3C,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x48,0x48,0x30,0x30,0x00,0x00, + 0x84,0x84,0x88,0x88,0x90,0x90,0xE0,0xE0, + 0x90,0x90,0x88,0x88,0x84,0x84,0x00,0x00, + 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, + 0x40,0x40,0x40,0x40,0x7E,0x7E,0x00,0x00, + 0xC6,0xC6,0xC6,0xC6,0xAA,0xAA,0xAA,0xAA, + 0x92,0x92,0x92,0x92,0x82,0x82,0x00,0x00, + 0xC2,0xC2,0xC2,0xC2,0xA2,0xA2,0x92,0x92, + 0x8A,0x8A,0x86,0x86,0x86,0x86,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82, + 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0xFC,0xFC,0x82,0x82,0x82,0x82,0x82,0x82, + 0xFC,0xFC,0x80,0x80,0x80,0x80,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82, + 0xBA,0xBA,0xC4,0xC4,0x7A,0x7A,0x00,0x00, + 0xFC,0xFC,0x82,0x82,0x82,0x82,0x82,0x82, + 0xFC,0xFC,0x84,0x84,0x82,0x82,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0x80,0x80,0x7C,0x7C, + 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0xFE,0xFE,0x10,0x10,0x10,0x10,0x10,0x10, + 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, + 0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82, + 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0x82,0x82,0x82,0x82,0x44,0x44,0x44,0x44, + 0x28,0x28,0x28,0x28,0x10,0x10,0x00,0x00, + 0x82,0x82,0x82,0x82,0x82,0x82,0x92,0x92, + 0x92,0x92,0x92,0x92,0x6C,0x6C,0x00,0x00, + 0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10, + 0x28,0x28,0x44,0x44,0x82,0x82,0x00,0x00, + 0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10, + 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, + 0xFE,0xFE,0x02,0x02,0x0C,0x0C,0x10,0x10, + 0x60,0x60,0x80,0x80,0xFE,0xFE,0x00,0x00, + 0x38,0x38,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x38,0x38,0x00,0x00, + 0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10, + 0x08,0x08,0x04,0x04,0x00,0x00,0x00,0x00, + 0x38,0x38,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x38,0x38,0x00,0x00, + 0x7C,0x7C,0x82,0x82,0xBA,0xBA,0xA2,0xA2, + 0xBA,0xBA,0x82,0x82,0x7C,0x7C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00 +}; + +/* End of BKG.C */ diff --git a/gbdk-lib/examples/ap/dscan/bkg.gbr b/gbdk-lib/examples/ap/dscan/bkg.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/dscan/bkg.h b/gbdk-lib/examples/ap/dscan/bkg.h @@ -0,0 +1,105 @@ +/* + + BKG.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 95 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : 1 Byte per entry. + + Convert to metatiles : No. + + This file was generated by GBTD v1.6 + +*/ + + +/* Bank of tiles. */ +#define bkgBank 0 + +/* Super Gameboy palette 0 */ +#define bkgSGBPal0c0 0 +#define bkgSGBPal0c1 0 +#define bkgSGBPal0c2 0 +#define bkgSGBPal0c3 0 + +/* Super Gameboy palette 1 */ +#define bkgSGBPal1c0 4104 +#define bkgSGBPal1c1 6 +#define bkgSGBPal1c2 0 +#define bkgSGBPal1c3 0 + +/* Super Gameboy palette 2 */ +#define bkgSGBPal2c0 4104 +#define bkgSGBPal2c1 6 +#define bkgSGBPal2c2 0 +#define bkgSGBPal2c3 0 + +/* Super Gameboy palette 3 */ +#define bkgSGBPal3c0 4104 +#define bkgSGBPal3c1 6 +#define bkgSGBPal3c2 0 +#define bkgSGBPal3c3 0 + +/* Gameboy Color palette 0 */ +#define bkgCGBPal0c0 32767 +#define bkgCGBPal0c1 25368 +#define bkgCGBPal0c2 16912 +#define bkgCGBPal0c3 0 + +/* Gameboy Color palette 1 */ +#define bkgCGBPal1c0 31744 +#define bkgCGBPal1c1 25600 +#define bkgCGBPal1c2 15360 +#define bkgCGBPal1c3 31 + +/* Gameboy Color palette 2 */ +#define bkgCGBPal2c0 29696 +#define bkgCGBPal2c1 21504 +#define bkgCGBPal2c2 13312 +#define bkgCGBPal2c3 31 + +/* Gameboy Color palette 3 */ +#define bkgCGBPal3c0 27648 +#define bkgCGBPal3c1 19456 +#define bkgCGBPal3c2 11264 +#define bkgCGBPal3c3 31 + +/* Gameboy Color palette 4 */ +#define bkgCGBPal4c0 23552 +#define bkgCGBPal4c1 17408 +#define bkgCGBPal4c2 9216 +#define bkgCGBPal4c3 31 + +/* Gameboy Color palette 5 */ +#define bkgCGBPal5c0 16896 +#define bkgCGBPal5c1 25344 +#define bkgCGBPal5c2 0 +#define bkgCGBPal5c3 31 + +/* Gameboy Color palette 6 */ +#define bkgCGBPal6c0 21120 +#define bkgCGBPal6c1 29568 +#define bkgCGBPal6c2 31744 +#define bkgCGBPal6c3 31 + +/* Gameboy Color palette 7 */ +#define bkgCGBPal7c0 32767 +#define bkgCGBPal7c1 32736 +#define bkgCGBPal7c2 0 +#define bkgCGBPal7c3 31744 +/* CGBpalette entries. */ +extern const unsigned char bkgCGB[]; +/* Start of tile array. */ +extern const unsigned char bkg[]; + +/* End of BKG.H */ diff --git a/gbdk-lib/examples/ap/dscan/bkg_c.c b/gbdk-lib/examples/ap/dscan/bkg_c.c @@ -0,0 +1,62 @@ +/* + + BKG_C.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 20 x 18 + Tile set : C:\SDK\gb-gb\2-0-15\examples\dscan\bkg.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + + This file was generated by GBMB v0.8 + +*/ + +#define bkg_cWidth 20 +#define bkg_cHeight 18 + +const unsigned char bkg_c[] = +{ + 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, + 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, + 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, + 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13, + 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13, + 0x02,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x04, + 0x04,0x04,0x04,0x04,0x04,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x04, + 0x04,0x04,0x04,0x04,0x04,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x05,0x05,0x05,0x05,0x05, + 0x05,0x05,0x05,0x05,0x05,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x07,0x07,0x07,0x07,0x07, + 0x07,0x07,0x07,0x07,0x07,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x09,0x09,0x09,0x09,0x09, + 0x09,0x09,0x09,0x09,0x09,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x0A,0x0A,0x0A,0x0A,0x0A, + 0x0A,0x0A,0x0A,0x0A,0x0A,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x0B,0x0B,0x0B,0x0B,0x0B, + 0x0B,0x0B,0x0B,0x0B,0x0B,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x0C,0x0C,0x0C,0x0C,0x0C, + 0x0C,0x0C,0x0C,0x0C,0x0C,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x0D,0x0D,0x0D,0x0D,0x0D, + 0x0D,0x0D,0x0D,0x0D,0x0D,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x0E,0x0E,0x0E,0x0E,0x0E, + 0x0E,0x0E,0x0E,0x0E,0x0E,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x0F,0x0F,0x0F,0x0F,0x0F, + 0x0F,0x0F,0x0F,0x0F,0x0F,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, +}; + +/* End of BKG_C.C */ diff --git a/gbdk-lib/examples/ap/dscan/bkg_c.gbm b/gbdk-lib/examples/ap/dscan/bkg_c.gbm Binary files differ. diff --git a/gbdk-lib/examples/ap/dscan/bkg_m.c b/gbdk-lib/examples/ap/dscan/bkg_m.c @@ -0,0 +1,62 @@ +/* + + BKG_M.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 20 x 18 + Tile set : C:\SDK\gb-gb\2-0-15\examples\dscan\bkg.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + + This file was generated by GBMB v0.8 + +*/ + +#define bkg_mWidth 20 +#define bkg_mHeight 18 + +const unsigned char bkg_m[] = +{ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02, +}; + +/* End of BKG_M.C */ diff --git a/gbdk-lib/examples/ap/dscan/bkg_m.gbm b/gbdk-lib/examples/ap/dscan/bkg_m.gbm Binary files differ. diff --git a/gbdk-lib/examples/ap/dscan/dscan.c b/gbdk-lib/examples/ap/dscan/dscan.c @@ -0,0 +1,751 @@ +/******************************************************************** + * Color Deep Scan * + * by * + * Mr. N.U. of TeamKNOx * + ********************************************************************/ + +#include <gb/gb.h> +#include <gb/cgb.h> +#include <stdint.h> +#include <stdlib.h> +#include <rand.h> + +/* bitmaps */ +#include "bkg.h" +#include "bkg.c" +#include "bkg_m.c" +#include "bkg_c.c" +#include "fore.h" +#include "fore.c" + +/* ************************************************************ */ + +const uint16_t bkg_p[] = +{ + bkgCGBPal0c0,bkgCGBPal0c1,bkgCGBPal0c2,bkgCGBPal0c3, + bkgCGBPal1c0,bkgCGBPal1c1,bkgCGBPal1c2,bkgCGBPal1c3, + bkgCGBPal2c0,bkgCGBPal2c1,bkgCGBPal2c2,bkgCGBPal2c3, + bkgCGBPal3c0,bkgCGBPal3c1,bkgCGBPal3c2,bkgCGBPal3c3, + bkgCGBPal4c0,bkgCGBPal4c1,bkgCGBPal4c2,bkgCGBPal4c3, + bkgCGBPal5c0,bkgCGBPal5c1,bkgCGBPal5c2,bkgCGBPal5c3, + bkgCGBPal6c0,bkgCGBPal6c1,bkgCGBPal6c2,bkgCGBPal6c3, + bkgCGBPal7c0,bkgCGBPal7c1,bkgCGBPal7c2,bkgCGBPal7c3 +}; + +const uint16_t obj_p[] = +{ + foreCGBPal0c0,foreCGBPal0c1,foreCGBPal0c2,foreCGBPal0c3, + foreCGBPal1c0,foreCGBPal1c1,foreCGBPal1c2,foreCGBPal1c3, + foreCGBPal2c0,foreCGBPal2c1,foreCGBPal2c2,foreCGBPal2c3, + foreCGBPal3c0,foreCGBPal3c1,foreCGBPal3c2,foreCGBPal3c3, + foreCGBPal4c0,foreCGBPal4c1,foreCGBPal4c2,foreCGBPal4c3, + foreCGBPal5c0,foreCGBPal5c1,foreCGBPal5c2,foreCGBPal5c3, + foreCGBPal6c0,foreCGBPal6c1,foreCGBPal6c2,foreCGBPal6c3, + foreCGBPal7c0,foreCGBPal7c1,foreCGBPal7c2,foreCGBPal7c3 +}; + +/* screen size */ +#define MIN_SX 5U /* min x (char) */ +#define MAX_SX (20U-MIN_SX) /* max x (char) */ +#define MIN_SY 5U /* min y (char) */ +#define MAX_SY (MIN_SY+13U) /* max y (char) */ + +#define DEF_SP 30U /* sprite null char code */ + +/* player */ +#define MIN_PX (MIN_SX*8U+8U) /* min x (dot) */ +#define MAX_PX (MAX_SX*8U-8U) /* max x (dot) */ +#define DEF_PX 80U /* ship x pos (dot) */ +#define DEF_PY (MIN_SY*8U) /* ship y pos (dot) */ +#define DEF_PC0 14U +#define DEF_PC1 15U +#define DEF_PF 8U + +/* bomb */ +#define MAX_TT 6U /* number */ +#define DEF_TS 2U /* sprite tile id */ +#define DEF_TC 2U /* sprite data id */ +#define DEF_TX (80U-6U) /* bomb x pos (dot) */ +#define DEF_TY (DEF_PY-14U) /* bomb y pos (dot) */ +#define MAX_TY (MAX_SY*8U) /* max y pos (dot) */ + +/* enemy */ +#define MAX_ET 10U /* number */ +#define DEF_ES0 (DEF_TS+MAX_TT) /* sprite tile id */ +#define DEF_ES1 (DEF_ES0+1U) +#define DEF_1EC0 32U +#define DEF_1EC1 48U +#define DEF_2EC0 64U +#define DEF_2EC1 80U +#define DEF_XEC0 96U /* sprite data(X) id */ +#define DEF_XEC1 112U /* sprite data(X) id */ +#define DEF_EY (DEF_PY+12U) +#define DEF_EH 10U +#define SUB_EX0 20U +#define SUB_EX1 (SUB_EX0-8U) +#define MIN_EX (SUB_EX0-16U) +#define MAX_EX (SUB_EX0+180U) +#define SPEED_EY (DEF_EY+DEF_EH*3U) +#define DEF_BC1 4U +#define DEF_BC2 5U + +/* kirai */ +#define MAX_KT 12U +#define DEF_KS (DEF_ES0+MAX_ET*2U) /* sprite tile id */ +#define DEF_KC 4U /* sprite data id */ +#define DEF_KX 0U /* bomb x pos (default_dot) */ +#define DEF_KY 0U /* bomb y pos (default_dot) */ +#define MIN_KY (DEF_PY+1U) /* min y pos (dot) */ + +unsigned char msg_tile[64]; + +const unsigned char * const msg_1up = "1UP"; +const unsigned char * const msg_lv = "LV"; + +const unsigned char * const msg_gover = "GAMEOVER"; +const unsigned char * const msg_pause = " PAUSE! "; +const unsigned char * const msg_start = " "; + +uint8_t pf, px, pp, pl; +uint16_t pw; +uint16_t ps; +uint8_t tf[MAX_TT]; +uint8_t tx[MAX_TT], ty[MAX_TT]; +uint8_t ef[MAX_ET], ex[MAX_ET], ey[MAX_ET]; +uint8_t kf[MAX_KT], kx[MAX_KT], ky[MAX_KT]; +uint8_t rnd_enemy, rnd_kirai; +uint8_t k_right, k_left; + +void set_sprite_attrb( uint8_t nb, uint8_t tile ) +{ + if( _cpu==CGB_TYPE ) { + set_sprite_prop( nb, tile ); + } +} + + +void set_bkg_attr( uint8_t x, uint8_t y, uint8_t sx, uint8_t sy, unsigned char *d ) +{ + uint8_t xx, yy; + + VBK_REG = 1; /* select palette bank */ + for( yy=0; yy<sy; yy++ ) { + for( xx=0; xx<sx; xx++ ) { + msg_tile[xx] = bkgCGB[(unsigned int)*d]; + d++; + } + set_bkg_tiles( x, y+yy, sx, 1, msg_tile ); + } + VBK_REG = 0; /* select data bank */ +} + +uint8_t make_rnd( uint8_t i ) +{ + return( arand()%(i+1) ); +} + +void show_score( uint16_t s ) +{ + uint16_t m; + uint8_t i, n, f; + unsigned char score[6]; + + f = 0; m = 10000; + for( i=0; i<5; i++ ) { + n = s/m; s = s%m; m = m/10; + if( (n==0)&&(f==0) ) { + score[i] = 0x20; /* ' ' */ + } else { + f = 1; + score[i] = 0x30+n; /* '0' - '9' */ + } + } + score[5] = 0x30; /* '0' */ + set_bkg_tiles( 4, 0, 6, 1, score ); +} + +void set_level( uint8_t i ) +{ + /* level */ + if( i < 9 ) { + rnd_enemy = 100-(i*12); /* 1% - */ + rnd_kirai = 50-(i*6); /* 2% - */ + } else { + rnd_enemy = 0; /* 100 % */ + rnd_kirai = 0; /* 100 % */ + } +} + +void show_level( uint8_t i ) +{ + unsigned char level[2]; + + if( i < 9 ) { + level[0] = 0x31+i; + } else { + level[0] = 0x41+i-9; + } + set_bkg_tiles( 19, 0, 1, 1, level ); + set_level( i ); +} + +void show_gover() +{ + set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_gover ); + pf = DEF_PF; +} + +void show_pause() +{ + set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_pause ); +} + +void hide_msg() +{ + set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_start ); +} + +void init_score() +{ + ps = 0; + show_score( ps ); + pp = 0; pl = 0; + show_level( pl ); +} + +void init_screen() +{ + uint8_t n; + + if( _cpu==CGB_TYPE ) { + /* Transfer color palette */ + set_bkg_palette( 0, 1, &bkg_p[0] ); + set_bkg_palette( 1, 1, &bkg_p[4] ); + set_bkg_palette( 2, 1, &bkg_p[8] ); + set_bkg_palette( 3, 1, &bkg_p[12] ); + set_bkg_palette( 4, 1, &bkg_p[16] ); + set_bkg_palette( 5, 1, &bkg_p[20] ); + set_bkg_palette( 6, 1, &bkg_p[24] ); + set_bkg_palette( 7, 1, &bkg_p[28] ); + set_sprite_palette( 0, 1, &obj_p[0] ); + set_sprite_palette( 1, 1, &obj_p[4] ); + set_sprite_palette( 2, 1, &obj_p[8] ); + set_sprite_palette( 3, 1, &obj_p[12] ); + set_sprite_palette( 4, 1, &obj_p[16] ); + set_sprite_palette( 5, 1, &obj_p[20] ); + set_sprite_palette( 6, 1, &obj_p[24] ); + set_sprite_palette( 7, 1, &obj_p[28] ); + + /* set attributes */ + set_bkg_attr( 0, 0, 20, 18, bkg_c ); + set_bkg_tiles( 0, 0, 20, 18, bkg_c ); + } else { + set_bkg_tiles( 0, 0, 20, 18, bkg_m ); + } + + pw = 50; + set_bkg_data( 0, 96, bkg ); + set_bkg_tiles( 0, 0, 3, 1, (unsigned char *)msg_1up ); + set_bkg_tiles( 16, 0, 2, 1, (unsigned char *)msg_lv ); + SHOW_BKG; + SPRITES_8x8; + set_sprite_data( 0, 128, fore ); + SHOW_SPRITES; + for( n=0; n<40; n++ ) { + set_sprite_tile( n, DEF_SP ); + move_sprite( n, 0, 0 ); + } +} + +void init_player() +{ + pf = 0; px = DEF_PX; + set_sprite_tile( 0, 0 ); + set_sprite_attrb( 0, foreCGB[0] ); + move_sprite( 0, px, DEF_PY ); + set_sprite_tile( 1, 1 ); + set_sprite_attrb( 1, foreCGB[1] ); + move_sprite( 1, px+8, DEF_PY ); +} + +void init_tama() +{ + uint8_t i; + + for( i=0; i<MAX_TT; i++ ) { + tf[i] = 0; + tx[i] = i*4+DEF_TX; + ty[i] = DEF_TY; + set_sprite_tile( i+DEF_TS, tf[i]+DEF_TC ); + set_sprite_attrb( i+DEF_TS, foreCGB[tf[i]+DEF_TC] ); + move_sprite( i+DEF_TS, tx[i], ty[i] ); + } +} + +void init_enemy() +{ + uint8_t i; + + for( i=0; i<MAX_ET; i++ ) { + ef[i] = 0; + ex[i] = 0; + ey[i] = 0; + set_sprite_tile( i*2+DEF_ES0, DEF_SP ); + set_sprite_tile( i*2+DEF_ES1, DEF_SP ); + move_sprite( i*2+DEF_ES0, ex[i], ey[i] ); + move_sprite( i*2+DEF_ES1, ex[i], ey[i] ); + } +} + +void init_kirai() +{ + uint8_t i; + + for( i=0; i<MAX_KT; i++ ) { + kf[i] = 0; + kx[i] = DEF_KX; + ky[i] = DEF_KY; + set_sprite_tile( i+DEF_KS, DEF_SP ); + move_sprite( i+DEF_KS, kx[i], ky[i] ); + } +} + +/* player */ +void player() +{ + uint8_t key; + uint8_t i; + uint16_t seed; + + key = joypad(); + /* pause */ + if( key & J_START ) { + if( pf == DEF_PF ) { + /* Initialize the random number generator */ + seed = DIV_REG; + waitpadup(); + seed |= ((uint16_t)DIV_REG << 8); + initarand(seed); + hide_msg(); + init_score(); + init_player(); + init_tama(); + init_enemy(); + init_kirai(); + delay( 500 ); + } else { + show_pause(); + waitpadup(); + key = joypad(); + while( !(key & J_START) ) { + key = joypad(); + if( key & J_DOWN ) { + if(pl > 0) + pl--; + show_level( pl ); + waitpadup(); + } else if( key & J_UP ) { + if(pl < 8) + pl++; + show_level( pl ); + waitpadup(); + } else if( key & J_LEFT ) { + while( joypad() & J_LEFT ) { + if(pw > 0) + pw--; + show_score( pw ); + delay( 250 ); + } + show_score( ps ); + } else if( key & J_RIGHT ) { + while( joypad() & J_RIGHT ) { + if(pw < 99) + pw++; + show_score( pw ); + delay( 250 ); + } + show_score( ps ); + } else if( key & J_SELECT ) { + i = k_right; + k_right = k_left; + k_left = i; + waitpadup(); + } + } + waitpadup(); + hide_msg(); + delay( 500 ); + } + return; + } + + /* dead */ + if( pf > 1 ) { + if( pf < DEF_PF ) { + set_sprite_tile( 0, pf*2+DEF_PC0 ); + set_sprite_attrb( 0, foreCGB[pf*2+DEF_PC0] ); + set_sprite_tile( 1, pf*2+DEF_PC1 ); + set_sprite_attrb( 1, foreCGB[pf*2+DEF_PC1] ); + pf++; + } else { + set_sprite_tile( 0, DEF_SP ); + set_sprite_tile( 1, DEF_SP ); + show_gover(); + } + return; + } + + /* move */ + if( (key&J_LEFT)&&(px>MIN_PX) ) { + px--; + move_sprite( 0, px, DEF_PY ); move_sprite( 1, px+8, DEF_PY ); + } else if( (key&J_RIGHT)&&(px<MAX_PX) ) { + px++; + move_sprite( 0, px, DEF_PY ); move_sprite( 1, px+8, DEF_PY ); + } + /* shot */ + if( key & k_left ) { /* change J_B to J_A */ + if( pf == 0 ) { + pf = 1; + for( i=0; i<MAX_TT; i++ ) { + if( tf[i] == 0 ) { + tf[i] = 1; tx[i] = px-4; ty[i] = DEF_PY; + break; + } + } + } + } else if( key & k_right ) { /* change J_A to J_B */ + if( pf == 0 ) { + pf = 1; + for( i=0; i<MAX_TT; i++ ) { + if( tf[i] == 0 ) { + tf[i] = 1; tx[i] = px+12; ty[i] = DEF_PY; + break; + } + } + } + } else if( pf == 1 ) { + pf = 0; + } +} + +/* bombs */ +void bombs() +{ + uint8_t i; + + for( i=0; i<MAX_TT; i++ ) { + if( tf[i] != 0 ) { + ty[i]++; + if( ty[i] > MAX_TY ) { + tf[i] = 0; tx[i] = i*4+DEF_TX; ty[i] = DEF_TY; + } else { + tf[i] = 3-tf[i]; + } + set_sprite_tile( i+DEF_TS, tf[i]+DEF_TC ); + set_sprite_attrb( i+DEF_TS, foreCGB[tf[i]+DEF_TC] ); + move_sprite( i+DEF_TS, tx[i], ty[i] ); + } + } +} + +/* enemys */ +void enemys() +{ + uint8_t i, j; + + for( i=0; i<MAX_ET; i++ ) { + if( ef[i] == 1 ) { + /* move right to left */ + ex[i]--; + if( (pl>0)&&(ey[i]<SPEED_EY) ) ex[i]--; + if( ex[i] <= MIN_EX ) { + ef[i] = 0; + set_sprite_tile( i*2+DEF_ES0, DEF_SP ); + set_sprite_tile( i*2+DEF_ES1, DEF_SP ); + } else { + /* new */ + if( ex[i]<MIN_SX*8+13 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 ); + } else if( ex[i]<MIN_SX*8+20 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+(ex[i]-MIN_SX*8-13) ); + } else if( ex[i]<MIN_SX*8+28 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+(ex[i]-MIN_SX*8-20) ); + set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+8 ); + } else if( ex[i]<MAX_SX*8+13 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+8 ); + } else if( ex[i]<MAX_SX*8+20 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+(ex[i]-MAX_SX*8-12)+7 ); + } else if( ex[i]<MAX_SX*8+28 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+(ex[i]-MAX_SX*8-20)+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 ); + } else { + set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 ); + } + /* new */ + move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] ); + move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] ); + /* check bomb */ + for( j=0; j<MAX_TT; j++ ) { + if( tf[j] != 0 ) { + if( (ty[j]>ey[i]-2)&&(ty[j]<ey[i]+2) ) { + if( (tx[j]>(ex[i]-SUB_EX0-5))&&(tx[j]<(ex[i]-SUB_EX1+5)) ) { + /* hit */ + tf[j] = 0; tx[j] = j*4+DEF_TX; ty[j] = DEF_TY; + set_sprite_tile( j+DEF_TS, tf[j]+DEF_TC ); + set_sprite_attrb( j+DEF_TS, foreCGB[tf[j]+DEF_TC] ); + move_sprite( j+DEF_TS, tx[j], ty[j] ); + ef[i] = 3; + set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 ); + set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] ); + set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 ); + set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] ); + } + } + } + } + if( make_rnd(rnd_kirai) == 0 ) { + if( ((ex[i]-SUB_EX0)>MIN_PX)&&((ex[i]-SUB_EX0)<MAX_PX) ) { + if( kf[i] == 0 ) { + /* shot kirai */ + kf[i] = 1; + kx[i] = ex[i]-SUB_EX0+4; + ky[i] = ey[i]-4; + } else if( kf[i+1] == 0 ) { + /* shot kirai */ + kf[i+1] = 1; + kx[i+1] = ex[i]-SUB_EX0+4; + ky[i+1] = ey[i]-4; + } else if( kf[i+2] == 0 ) { + /* shot kirai */ + kf[i+2] = 1; + kx[i+2] = ex[i]-SUB_EX0+4; + ky[i+2] = ey[i]-4; + } + } + } + } + } else if( ef[i] == 2 ) { + /* move left to right */ + ex[i]++; + if( (pl>0)&&(ey[i]<SPEED_EY) ) ex[i]++; + if( ex[i] >= MAX_EX ) { + ef[i] = 0; + set_sprite_tile( i*2+DEF_ES0, DEF_SP ); + set_sprite_tile( i*2+DEF_ES1, DEF_SP ); + } else { + /* new */ + if( i==9 ) { + if( ex[i]<MIN_SX*8+13 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 ); + } else if( ex[i]<MIN_SX*8+20 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+(ex[i]-MIN_SX*8-13) ); + } else if( ex[i]<MIN_SX*8+28 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+(ex[i]-MIN_SX*8-20) ); + set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+8 ); + } else if( ex[i]<MAX_SX*8+13 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+8 ); + } else if( ex[i]<MAX_SX*8+20 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+(ex[i]-MAX_SX*8-12)+7 ); + } else if( ex[i]<MAX_SX*8+28 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+(ex[i]-MAX_SX*8-20)+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 ); + } else { + set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 ); + } + } else { + if( ex[i]<MIN_SX*8+13 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 ); + } else if( ex[i]<MIN_SX*8+20 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+(ex[i]-MIN_SX*8-13) ); + } else if( ex[i]<MIN_SX*8+28 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+(ex[i]-MIN_SX*8-20) ); + set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+8 ); + } else if( ex[i]<MAX_SX*8+13 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+8 ); + } else if( ex[i]<MAX_SX*8+20 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+(ex[i]-MAX_SX*8-12)+7 ); + } else if( ex[i]<MAX_SX*8+28 ) { + set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+(ex[i]-MAX_SX*8-20)+8 ); + set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 ); + } else { + set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 ); + set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 ); + } + } + /* new */ + move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] ); + move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] ); + /* check bomb */ + for( j=0; j<MAX_TT; j++ ) { + if( tf[j] != 0 ) { + if( (ty[j]>ey[i]-2)&&(ty[j]<ey[i]+2) ) { + if( (tx[j]>(ex[i]-SUB_EX0-5))&&(tx[j]<(ex[i]-SUB_EX1+5)) ) { + /* hit */ + tf[j] = 0; tx[j] = j*4+DEF_TX; ty[j] = DEF_TY; + set_sprite_tile( j+DEF_TS, tf[j]+DEF_TC ); + set_sprite_attrb( j+DEF_TS, foreCGB[tf[j]+DEF_TC] ); + move_sprite( j+DEF_TS, tx[j], ty[j] ); + ef[i] = 3; + set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 ); + set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] ); + set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 ); + set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] ); + } + } + } + } + if( make_rnd(rnd_kirai) == 0 ) { + if( ((ex[i]-SUB_EX0)>MIN_PX)&&((ex[i]-SUB_EX0)<MAX_PX) ) { + if( kf[i] == 0 ) { + /* shot kirai */ + kf[i] = 1; + kx[i] = ex[i]-SUB_EX0+4; + ky[i] = ey[i]-4; + } else if( kf[i+1] == 0 ) { + /* shot kirai */ + kf[i+1] = 1; + kx[i+1] = ex[i]-SUB_EX0+4; + ky[i+1] = ey[i]-4; + } else if( kf[i+2] == 0 ) { + /* shot kirai */ + kf[i+2] = 1; + kx[i+2] = ex[i]-SUB_EX0+4; + ky[i+2] = ey[i]-4; + } + } + } + } + } else if( ef[i] >= 3 ) { + if( ef[i] > 4 ) { + ef[i] = 0; + set_sprite_tile( i*2+DEF_ES0, DEF_SP ); + set_sprite_tile( i*2+DEF_ES1, DEF_SP ); + if( i == 9 ) { + ps += 100; show_score( ps ); pp++; + set_level( pl-1 ); + } else { + ps += (i+1); show_score( ps ); pp++; + } + } else { + set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 ); + set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] ); + set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 ); + set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] ); + ef[i]++; + } + } else if( i == 9 ) { + if( pp > 20 ) { + pp = 0; + pl++; show_level( pl ); + /* X */ + ey[i] = i*DEF_EH+DEF_EY; + ef[i] = i%2+1; + ex[i] = MIN_EX; + set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 ); + set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_XEC0] ); + set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 ); + set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_XEC1] ); + move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] ); + move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] ); + } + } else if( make_rnd(rnd_enemy) == 0 ) { + if( !((pl<4)&&(i==0)) ) { + /* create */ + ey[i] = i*DEF_EH+DEF_EY; + ef[i] = i%2+1; + if( ef[i] == 1 ) { + ex[i] = MAX_EX; + set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 ); + set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_1EC0] ); + set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 ); + set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_1EC1] ); + } else { + ex[i] = MIN_EX; + set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 ); + set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_2EC0] ); + set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 ); + set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_2EC1] ); + } + move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] ); + move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] ); + } + } + } +} + +/* kirai */ +void kirai() +{ + uint8_t i; + + for( i=0; i<MAX_KT; i++ ) { + if( kf[i] != 0 ) { + ky[i]--; + if( kf[i] >=3 ) { + kf[i]++; + if( (kx[i]>(px-5))&&(kx[i]<(px+12)) ) { + if( pf < 2 ) { + /* out!! */ + pf = 2; + } + } + if( kf[i] >= 6 ) { + kf[i] = 0; kx[i] = DEF_KX; ky[i] = DEF_KY; + } + } else if( ky[i] <= MIN_KY ) { + kf[i] = 3; + } else { + kf[i] = 3-kf[i]; + } + set_sprite_tile( i+DEF_KS, kf[i]+DEF_KC ); + set_sprite_attrb( i+DEF_KS, foreCGB[kf[i]+DEF_KC] ); + move_sprite( i+DEF_KS, kx[i], ky[i] ); + } + } +} + +/*--------------------------------------------------------------------------* + | main program | + *--------------------------------------------------------------------------*/ +void main() +{ + disable_interrupts(); + DISPLAY_OFF; + + initarand(((uint16_t)DIV_REG << 8)); + + init_screen(); + init_score(); + init_player(); + init_tama(); + init_enemy(); + init_kirai(); + show_gover(); + k_right = J_A; + k_left = J_B; + DISPLAY_ON; + enable_interrupts(); + + while(1) { + delay( pw ); + player(); + bombs(); + enemys(); + kirai(); + } +} diff --git a/gbdk-lib/examples/ap/dscan/fore.c b/gbdk-lib/examples/ap/dscan/fore.c @@ -0,0 +1,306 @@ +/* + + FORE.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 127 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : 1 Byte per entry. + + Convert to metatiles : No. + + This file was generated by GBTD v1.6 + +*/ + +/* CGBpalette entries. */ +const unsigned char foreCGB[] = +{ + 0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x05, + 0x05,0x05,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04, + 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04, + 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04, + 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04 +}; +/* Start of tile array. */ +const unsigned char fore[] = +{ + 0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03, + 0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x00,0x00, + 0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xC0, + 0xFE,0xFE,0xFC,0xFC,0xF8,0xF8,0x00,0x00, + 0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18, + 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x10,0x30,0x38, + 0x0C,0x1C,0x00,0x08,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x08,0x0C,0x1C, + 0x30,0x38,0x00,0x10,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x04,0x08,0x08,0x14,0x14,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x10,0x08,0x08,0x14,0x14,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x08,0x14,0x1C,0x1C,0x14,0x00,0x00, + 0x08,0x08,0x08,0x08,0x41,0x41,0x2A,0x2A, + 0x2A,0x3E,0x14,0x1C,0x1C,0x14,0x08,0x00, + 0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00, + 0x41,0x41,0x00,0x00,0x1C,0x1C,0x22,0x3E, + 0x00,0x00,0x08,0x00,0x04,0x00,0x11,0x00, + 0x11,0x00,0x04,0x00,0x08,0x00,0x00,0x00, + 0x00,0x00,0x10,0x00,0x20,0x00,0x88,0x00, + 0x88,0x00,0x20,0x00,0x10,0x00,0x00,0x00, + 0x10,0x00,0x08,0x00,0x21,0x00,0x02,0x00, + 0x02,0x00,0x21,0x00,0x08,0x00,0x10,0x00, + 0x08,0x00,0x10,0x00,0x84,0x00,0x40,0x00, + 0x40,0x00,0x84,0x00,0x10,0x00,0x08,0x00, + 0x10,0x00,0x01,0x00,0x40,0x00,0x04,0x00, + 0x04,0x00,0x40,0x00,0x01,0x00,0x10,0x00, + 0x08,0x00,0x80,0x00,0x02,0x00,0x20,0x00, + 0x20,0x00,0x02,0x00,0x80,0x00,0x08,0x00, + 0x00,0x10,0x01,0x0B,0x01,0x3E,0x64,0x7B, + 0x73,0x7C,0x3F,0x38,0x1F,0x1C,0x00,0x00, + 0x00,0x08,0x80,0xD0,0x80,0x7C,0x26,0xDE, + 0xCE,0x3E,0xFC,0x1C,0xF8,0x38,0x00,0x00, + 0x00,0x22,0x05,0x93,0x01,0x7E,0x5E,0x61, + 0x1F,0x70,0x2F,0xB0,0x1F,0x30,0x00,0x00, + 0x00,0x44,0xA0,0xC9,0x80,0x7E,0x7A,0x86, + 0xF8,0x0E,0xF4,0x0D,0xF8,0x0C,0x00,0x00, + 0x00,0x21,0x05,0x90,0x06,0x78,0x6A,0x76, + 0x10,0x7F,0x20,0xBF,0x18,0x37,0x00,0x00, + 0x00,0x84,0xA0,0x09,0x60,0x1E,0x56,0x6E, + 0x08,0xFE,0x04,0xFD,0x18,0xEC,0x00,0x00, + 0x00,0x00,0x60,0x60,0x70,0x74,0xFE,0xFE, + 0xDC,0xFE,0x7E,0x7E,0x37,0x3F,0x00,0x00, + 0x00,0x00,0x06,0x06,0x0E,0x2E,0x7F,0x7F, + 0x3B,0x7F,0x7E,0x7E,0xEC,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x04,0x40,0x40,0x40,0x62, + 0xF0,0xF0,0xF4,0xFC,0x7E,0x7E,0x00,0x00, + 0x00,0x00,0x00,0x20,0x02,0x02,0x02,0x46, + 0x0F,0x0F,0x2F,0x3F,0x7E,0x7E,0x00,0x00, + 0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x00, + 0x40,0x48,0x40,0x40,0xF0,0xF0,0x00,0x00, + 0x00,0x20,0x00,0x00,0x00,0x04,0x00,0x00, + 0x02,0x12,0x02,0x02,0x0F,0x0F,0x00,0x00, + 0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x40,0x40,0x00,0x00, + 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x02,0x02,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x30, + 0x00,0x40,0x00,0x40,0x00,0x3F,0x00,0x00, + 0x00,0x00,0x00,0x02,0x01,0x0D,0x01,0x31, + 0x01,0x41,0x01,0x41,0x01,0x3F,0x00,0x00, + 0x00,0x00,0x02,0x02,0x03,0x0F,0x03,0x33, + 0x03,0x43,0x03,0x43,0x03,0x3F,0x00,0x00, + 0x00,0x00,0x02,0x02,0x07,0x0F,0x07,0x37, + 0x07,0x47,0x07,0x47,0x07,0x3F,0x00,0x00, + 0x00,0x00,0x02,0x02,0x0F,0x0F,0x0F,0x3F, + 0x0F,0x4F,0x0F,0x4F,0x0F,0x3F,0x00,0x00, + 0x00,0x00,0x02,0x02,0x0F,0x0F,0x1F,0x3F, + 0x1F,0x5F,0x1F,0x5F,0x1F,0x3F,0x00,0x00, + 0x00,0x00,0x02,0x02,0x0F,0x0F,0x3F,0x3F, + 0x3F,0x7F,0x3F,0x7F,0x3F,0x3F,0x00,0x00, + 0x00,0x00,0x02,0x02,0x0F,0x0F,0x3F,0x3F, + 0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x00,0x00, + 0x00,0x00,0x02,0x02,0x0F,0x0F,0x3F,0x3F, + 0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x00,0x00, + 0x00,0x00,0x02,0x02,0x0E,0x0F,0x3E,0x3E, + 0x7E,0x7E,0x7E,0x7E,0x3E,0x3F,0x00,0x00, + 0x00,0x00,0x00,0x02,0x0C,0x0D,0x3C,0x3C, + 0x7C,0x7C,0x7C,0x7C,0x3C,0x3F,0x00,0x00, + 0x00,0x00,0x00,0x02,0x08,0x0D,0x38,0x38, + 0x78,0x78,0x78,0x78,0x38,0x3F,0x00,0x00, + 0x00,0x00,0x00,0x02,0x00,0x0D,0x30,0x30, + 0x70,0x70,0x70,0x70,0x30,0x3F,0x00,0x00, + 0x00,0x00,0x00,0x02,0x00,0x0D,0x20,0x30, + 0x60,0x60,0x60,0x60,0x20,0x3F,0x00,0x00, + 0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x30, + 0x40,0x40,0x40,0x40,0x00,0x3F,0x00,0x00, + 0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x30, + 0x00,0x40,0x00,0x40,0x00,0x3F,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x72, + 0x00,0x0E,0x00,0x12,0x00,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72, + 0x02,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72, + 0x06,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72, + 0x0E,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x12,0x72, + 0x1E,0x1E,0x12,0x12,0x00,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x32,0x72, + 0x3E,0x3E,0x32,0x32,0x20,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x72,0x72, + 0x7E,0x7E,0x72,0x72,0x60,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0xF2,0xF2, + 0xFE,0xFE,0xF2,0xF2,0xE0,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0xF2,0xF2, + 0xFE,0xFE,0xF2,0xF2,0xE0,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2, + 0xFC,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2, + 0xF8,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2, + 0xF0,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xF2, + 0xE0,0xEE,0xE0,0xF2,0xE0,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xF2, + 0xC0,0xCE,0xC0,0xD2,0xC0,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xF2, + 0x80,0x8E,0x80,0x92,0x80,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x72, + 0x00,0x0E,0x00,0x12,0x00,0xE0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x4E, + 0x00,0x70,0x00,0x48,0x00,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x4F, + 0x01,0x71,0x01,0x49,0x01,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x4F, + 0x03,0x73,0x03,0x4B,0x03,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x07,0x4F, + 0x07,0x77,0x07,0x4F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F, + 0x0F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F, + 0x1F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F, + 0x3F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F, + 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F, + 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x4E,0x4E, + 0x7E,0x7E,0x4E,0x4E,0x06,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x4C,0x4E, + 0x7C,0x7C,0x4C,0x4C,0x04,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x48,0x4E, + 0x78,0x78,0x48,0x48,0x00,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E, + 0x70,0x70,0x40,0x48,0x00,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E, + 0x60,0x70,0x40,0x48,0x00,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E, + 0x40,0x70,0x40,0x48,0x00,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x4E, + 0x00,0x70,0x00,0x48,0x00,0x07,0x00,0x00, + 0x00,0x00,0x00,0x40,0x00,0xB0,0x00,0x0C, + 0x00,0x02,0x00,0x02,0x00,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x40,0x00,0xB0,0x00,0x0C, + 0x02,0x02,0x02,0x02,0x00,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x40,0x00,0xB0,0x04,0x0C, + 0x06,0x06,0x06,0x06,0x04,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x40,0x00,0xB0,0x0C,0x0C, + 0x0E,0x0E,0x0E,0x0E,0x0C,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x40,0x10,0xB0,0x1C,0x1C, + 0x1E,0x1E,0x1E,0x1E,0x1C,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x40,0x30,0xB0,0x3C,0x3C, + 0x3E,0x3E,0x3E,0x3E,0x3C,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0x70,0xF0,0x7C,0x7C, + 0x7E,0x7E,0x7E,0x7E,0x7C,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0xFC, + 0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0xFC, + 0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0xFC, + 0xFC,0xFE,0xFC,0xFE,0xFC,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xF8,0xFC, + 0xF8,0xFA,0xF8,0xFA,0xF8,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xF0,0xFC, + 0xF0,0xF2,0xF0,0xF2,0xF0,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xE0,0xF0,0xE0,0xEC, + 0xE0,0xE2,0xE0,0xE2,0xE0,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xC0,0xF0,0xC0,0xCC, + 0xC0,0xC2,0xC0,0xC2,0xC0,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x40,0x80,0xB0,0x80,0x8C, + 0x80,0x82,0x80,0x82,0x80,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x40,0x00,0xB0,0x00,0x0C, + 0x00,0x02,0x00,0x02,0x00,0xFC,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x07,0x07, + 0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F, + 0x0F,0x0F,0x0F,0x0F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F, + 0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F, + 0x3F,0x3F,0x0F,0x0F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F, + 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F, + 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x4E,0x4E, + 0x7E,0x7E,0x4E,0x4E,0x06,0x06,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x4C,0x4C, + 0x7C,0x7C,0x4C,0x4C,0x04,0x04,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x48, + 0x78,0x78,0x48,0x48,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40, + 0x70,0x70,0x40,0x40,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40, + 0x60,0x60,0x40,0x40,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40, + 0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04, + 0x06,0x06,0x06,0x06,0x04,0x04,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C, + 0x0E,0x0E,0x0E,0x0E,0x0C,0x0C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x10,0x10,0x1C,0x1C, + 0x1E,0x1E,0x1E,0x1E,0x1C,0x1C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x30,0x30,0x3C,0x1C, + 0x3E,0x3E,0x3E,0x1E,0x3C,0x3C,0x00,0x00, + 0x00,0x00,0x40,0x40,0x70,0x70,0x7C,0x5C, + 0x7E,0x3E,0x7E,0x5E,0x7C,0x7C,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0x5C, + 0xFE,0xBE,0xFE,0x5E,0xFC,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0x5C, + 0xFE,0xBE,0xFE,0x5E,0xFC,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0x5C, + 0xFC,0xBC,0xFC,0x5C,0xFC,0xFC,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xF8,0x58, + 0xF8,0xB8,0xF8,0x58,0xF8,0xF8,0x00,0x00, + 0x00,0x00,0x40,0x40,0xF0,0xF0,0xF0,0x50, + 0xF0,0xB0,0xF0,0x50,0xF0,0xF0,0x00,0x00, + 0x00,0x00,0x40,0x40,0xE0,0xE0,0xE0,0x40, + 0xE0,0xA0,0xE0,0x40,0xE0,0xE0,0x00,0x00, + 0x00,0x00,0x40,0x40,0xC0,0xC0,0xC0,0x40, + 0xC0,0x80,0xC0,0x40,0xC0,0xC0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00, + 0x80,0x80,0x80,0x00,0x80,0x80,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +/* End of FORE.C */ diff --git a/gbdk-lib/examples/ap/dscan/fore.gbr b/gbdk-lib/examples/ap/dscan/fore.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/dscan/fore.h b/gbdk-lib/examples/ap/dscan/fore.h @@ -0,0 +1,105 @@ +/* + + FORE.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 127 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : 1 Byte per entry. + + Convert to metatiles : No. + + This file was generated by GBTD v1.6 + +*/ + + +/* Bank of tiles. */ +#define foreBank 0 + +/* Super Gameboy palette 0 */ +#define foreSGBPal0c0 0 +#define foreSGBPal0c1 0 +#define foreSGBPal0c2 0 +#define foreSGBPal0c3 18 + +/* Super Gameboy palette 1 */ +#define foreSGBPal1c0 6108 +#define foreSGBPal1c1 8935 +#define foreSGBPal1c2 6596 +#define foreSGBPal1c3 6368 + +/* Super Gameboy palette 2 */ +#define foreSGBPal2c0 6108 +#define foreSGBPal2c1 8935 +#define foreSGBPal2c2 6596 +#define foreSGBPal2c3 6368 + +/* Super Gameboy palette 3 */ +#define foreSGBPal3c0 6108 +#define foreSGBPal3c1 8935 +#define foreSGBPal3c2 6596 +#define foreSGBPal3c3 6368 + +/* Gameboy Color palette 0 */ +#define foreCGBPal0c0 32767 +#define foreCGBPal0c1 25368 +#define foreCGBPal0c2 19026 +#define foreCGBPal0c3 0 + +/* Gameboy Color palette 1 */ +#define foreCGBPal1c0 32344 +#define foreCGBPal1c1 31 +#define foreCGBPal1c2 0 +#define foreCGBPal1c3 32767 + +/* Gameboy Color palette 2 */ +#define foreCGBPal2c0 32344 +#define foreCGBPal2c1 31 +#define foreCGBPal2c2 25368 +#define foreCGBPal2c3 32767 + +/* Gameboy Color palette 3 */ +#define foreCGBPal3c0 32344 +#define foreCGBPal3c1 32767 +#define foreCGBPal3c2 992 +#define foreCGBPal3c3 1023 + +/* Gameboy Color palette 4 */ +#define foreCGBPal4c0 32344 +#define foreCGBPal4c1 32767 +#define foreCGBPal4c2 31744 +#define foreCGBPal4c3 31 + +/* Gameboy Color palette 5 */ +#define foreCGBPal5c0 32344 +#define foreCGBPal5c1 31 +#define foreCGBPal5c2 0 +#define foreCGBPal5c3 31744 + +/* Gameboy Color palette 6 */ +#define foreCGBPal6c0 32767 +#define foreCGBPal6c1 25368 +#define foreCGBPal6c2 19026 +#define foreCGBPal6c3 0 + +/* Gameboy Color palette 7 */ +#define foreCGBPal7c0 32767 +#define foreCGBPal7c1 25368 +#define foreCGBPal7c2 19026 +#define foreCGBPal7c3 0 +/* CGBpalette entries. */ +extern const unsigned char foreCGB[]; +/* Start of tile array. */ +extern const unsigned char fore[]; + +/* End of FORE.H */ diff --git a/gbdk-lib/examples/ap/filltest/Makefile b/gbdk-lib/examples/ap/filltest/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = filltest.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/filltest/filltest.c b/gbdk-lib/examples/ap/filltest/filltest.c @@ -0,0 +1,60 @@ +/* Sample Program to demonstrate the drawing functions in GBDK */ +/* Jon Fuge jonny@q-continuum.demon.co.uk */ + +#include <gb/gb.h> +#include <stdint.h> +#include <gb/drawing.h> + +void linetest(uint8_t x, uint8_t y, uint8_t w) { + color(DKGREY,WHITE,SOLID); + for (int i = -w; i <= w; i++) line(x,y,x+i,y-w); + for (int i = -w; i <= w; i++) line(x,y,x+w,y+i); + for (int i = -w; i <= w; i++) line(x,y,x+i,y+w); + for (int i = -w; i <= w; i++) line(x,y,x-w,y+i); +} + +void main(void) +{ + uint8_t a,b,c,d,e; + c=0; + /* Draw many characters on the screen with different fg and bg colours */ + for (a=0; a<=15; a++) { + for (b=0; b<=15; b++) { + gotogxy(b,a); + d=a/4; + e=b/4; + if (d==e) { + d=3-e; + } + color(d,e,SOLID); + gprintf("%c",c++); + } + } + + /* Draw two circles, a line, and two boxes in different drawing modes */ + color(LTGREY,WHITE,SOLID); + circle(140,20,15,M_FILL); + color(BLACK,WHITE,SOLID); + circle(140,20,10,M_NOFILL); + color(DKGREY,WHITE,XOR); + circle(120,40,30,M_FILL); + line(0,0,159,143); + color(BLACK,LTGREY,SOLID); + box(0,130,40,143,M_NOFILL); + box(50,130,90,143,M_FILL); + + + linetest(130, 100, 20); + + /* Scroll the screen using the hardest method imaginable :) */ + for (c=0; c<=143; c++) { + for (b=0; b<=142; b++) { + for (a=0; a<=159; a++) { + color(getpix(a,b+1),WHITE,SOLID); + plot_point(a,b); + } + color(WHITE,WHITE,SOLID); + } + line(0,143,159,143); + } +} diff --git a/gbdk-lib/examples/ap/fonts/Makefile b/gbdk-lib/examples/ap/fonts/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = fonts.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/fonts/fonts.c b/gbdk-lib/examples/ap/fonts/fonts.c @@ -0,0 +1,56 @@ +/* + fonts.c + Simple example of how to use multiple fonts on the GB + Michael Hope, 1999. +*/ + +#include <stdio.h> +#include <gb/font.h> +#include <gb/console.h> +#include <gb/drawing.h> + +void main(void) +{ + font_t ibm_font, italic_font, min_font; + int i; + + /* First, init the font system */ + font_init(); + + /* Load all the fonts that we can */ + ibm_font = font_load(font_ibm); /* 96 tiles */ + italic_font = font_load(font_italic); /* 93 tiles */ + + /* Load this one with dk grey background and white foreground */ + color(WHITE, DKGREY, SOLID); + + min_font = font_load(font_min); + + /* Turn scrolling off (why not?) */ + mode(get_mode() | M_NO_SCROLL); + + /* Print some text! */ + + /* IBM font */ + font_set(ibm_font); + printf("Font demo.\n\n"); + + printf("IBM Font #!?123\n"); + + /* In italic */ + font_set(italic_font); + for (i=1; i!=5; i++) { + printf("In italics, line %u\n", i); + } + + /* With a minimal, colour changed font */ + font_set(min_font); + printf("Minimal 36 tile font\n"); + + /* Done */ + font_set(ibm_font); + printf("\nDone!"); +} + + + diff --git a/gbdk-lib/examples/ap/galaxy/Makefile b/gbdk-lib/examples/ap/galaxy/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = galaxy.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/galaxy/galaxy.c b/gbdk-lib/examples/ap/galaxy/galaxy.c @@ -0,0 +1,632 @@ +/* + * C version of the 'space' assembly demo. + * + * Little demo illustrating how to use the graphical possibilities + * of the GB (background, window and animated sprite) + * I have used fixed-point values for both the position and + * speed of objects to get smooth movements + * + * OBJ data : 0x8000 -> 0x8FFF (unsigned) + * Window data : 0x8800 -> 0x97FF (unsigned) + * Background data : 0x8800 -> 0x97FF (signed) + * + * Tiled 0xFC -> 0xFF are standard tiles (all black -> all white) + * + * Keys: + * Arrow keys : Change the speed (and direction) of the sprite + * Arrow keys + A : Change the speed (and direction) of the window + * Arrow keys + B : Change the speed (and direction) of the background + * START : Open/close the door + * SELECT : Basic fading effect + * + * Note that the window is kept in the lower right part of the screen + * since it can't be made transparent + */ + +#include <gb/gb.h> +#include <stdint.h> + +const unsigned char std_data[] = { + + /* Basic tiles (0xFC to 0xFF) */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +const unsigned char earth_data[] = { + + /* Tile 0x00 */ + 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87, + 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2, + 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0, + 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A, + 0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x08 */ + 0x07,0x07,0x1E,0x19,0x20,0x3F,0x40,0x7F,0x42,0x7D,0x81,0xFE,0x81,0xFE,0x83,0xFC, + 0xD7,0xA8,0xBB,0xC4,0x6E,0x51,0x7C,0x43,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0xE8,0x18,0xF4,0x0C,0xF4,0x0C,0xFE,0x02,0xFE,0x02,0xFE,0x02, + 0xFE,0x02,0x7E,0x82,0x3C,0xC4,0x3C,0xC4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1B,0x1C,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xE0,0x9F,0x90,0xEF,0x89,0xF6, + 0x8D,0xF2,0x9F,0xE0,0x5E,0x61,0x6F,0x50,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xB0,0x70,0x28,0xD8,0x04,0xFC,0x2C,0xD4,0x1E,0xE2,0x1E,0xE2,0x3E,0xC2, + 0x7E,0x82,0xB6,0x4A,0xE4,0x1C,0xC4,0x3C,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x10 */ + 0x07,0x07,0x18,0x1F,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xEE,0x91,0xF1,0x8E,0xE0,0x9F, + 0xE0,0x9F,0xF1,0x8E,0x71,0x4E,0x72,0x4D,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xF0,0x30,0x08,0xF8,0x04,0xFC,0x04,0xFC,0x02,0xFE,0x02,0xFE,0x92,0x6E, + 0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1, + 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2, + 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x18 */ + 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE, + 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E, + 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 +}; + +const unsigned char frame_data[] = { + + /* Tile 0x00 */ + 0xFF,0x00,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F, + 0xFF,0x00,0x01,0xFE,0x03,0xFC,0x07,0xF8,0x0F,0xF0,0x1F,0xE0,0x3F,0xC0,0x7F,0x80, + 0xFF,0x00,0xFE,0x01,0xFC,0x03,0xF8,0x07,0xF0,0x0F,0xE0,0x1F,0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tile 0x10 */ + 0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01, + 0x01,0xFF,0x01,0xFE,0x03,0xFC,0x77,0xF8,0xFF,0x98,0xEF,0xB8,0xCF,0xF8,0x7F,0xF0, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x0E,0xFF,0x13,0xFD,0x17,0xF9,0x1F,0xFF,0x0E, + 0x80,0x7F,0x81,0x7E,0x83,0x7C,0x87,0x78,0x8F,0x70,0x9F,0x60,0xBF,0x40,0xFF,0x7F, + 0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0xFF,0xFF, + + /* Door1 */ + + /* Tile 0x15 */ + 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF, + + /* Door2 */ + + /* Tile 0x18 */ + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF, + 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF, + 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + + /* Door3 */ + + /* Tile 0x1C */ + 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xF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F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF +}; + +/* + * Image size: 0x40 x 0x40 + * Number of tiles (total - unique): 0x40 - 0x2D + */ + +const unsigned char bkg_tiles[] = { + 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC, + 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A, + 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC, + 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14, + 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC, + 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20, + 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26, + 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 +}; + +/* + * Image size: 0x10 x 0x70 + * Number of tiles (total - unique): 0x1C - 0x1C + */ + +const unsigned char earth_tiles[] = { + 0x00,0x02, + 0x04,0x06, + 0x08,0x0A, + 0x0C,0x0E, + 0x10,0x12, + 0x14,0x16, + 0x18,0x1A +}; + +/* + * Image size: 0x80 x 0x50 + * Number of tiles (total - unique): 0xA0 - 0x15 + */ + +const unsigned char frame_tiles[] = { + 0x80,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x84, + 0x85,0x86,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x8B,0x8C, + 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F, + 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90, + 0x8E,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0x8D, + 0x85,0x90,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x82,0x8C, + 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F, + 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90, + 0x8E,0x91,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0x92,0x8D, + 0x93,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x94 +}; + +/* + * Image size: 0x60 x 0x30 + * Number of tiles (total - unique): 0x48 - 0x03 + */ + +const unsigned char door1_tiles[] = { + 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95, + 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96, + 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97, + 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95, + 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96, + 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97, + + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC +}; + +/* + * Image size: 0x60 x 0x30 + * Number of tiles (total - unique): 0x48 - 0x04 + */ + +const unsigned char door2_tiles[] = { + 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98, + 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99, + 0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A, + 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98, + 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99, + 0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B, + + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, +}; + +/* + * Image size: 0x60 x 0x30 + * Number of tiles (total - unique): 0x48 - 0x04 + */ + +const unsigned char door3_tiles[] = { + 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C, + 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D, + 0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E, + 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C, + 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D, + 0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F, + + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC +}; + +/* + * Image size: 0x60 x 0x30 + * Number of tiles (total - unique): 0x48 - 0x01 + */ + +const unsigned char door4_tiles[] = { + 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95, + 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96, + 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97, + 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95, + 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96, + 0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0, + + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, + 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC +}; + +/* Should really be const, but sdcc doesnt yet support it. */ +const unsigned char * const film[] = { + &door1_tiles[0x0C*0], + &door2_tiles[0x0C*0], + &door3_tiles[0x0C*0], + &door4_tiles[0x0C*0], + &door1_tiles[0x0C*1], + &door2_tiles[0x0C*1], + &door3_tiles[0x0C*1], + &door4_tiles[0x0C*1], + &door1_tiles[0x0C*2], + &door2_tiles[0x0C*2], + &door3_tiles[0x0C*2], + &door4_tiles[0x0C*2], + &door1_tiles[0x0C*3], + &door2_tiles[0x0C*3], + &door3_tiles[0x0C*3], + &door4_tiles[0x0C*3], + &door1_tiles[0x0C*4], + &door2_tiles[0x0C*4], + &door3_tiles[0x0C*4], + &door4_tiles[0x0C*4], + &door1_tiles[0x0C*5], + &door2_tiles[0x0C*5], + &door3_tiles[0x0C*5], + &door4_tiles[0x0C*5], + &door1_tiles[0x0C*6] +}; + +#define NBDFRAMES 0x18 /* Nb frames for the door */ +#define NBSFRAMES 0x07 /* Nb frames for the sprite */ +#define WINSZX 0x80 /* Size of the picture in the window */ +#define WINSZY 0x50 +#define MINWINX (MAXWNDPOSX-WINSZX+1) /* Bounds of the window origin */ +#define MINWINY (MAXWNDPOSY-WINSZY+1) +#define MAXWINX MAXWNDPOSX +#define MAXWINY MAXWNDPOSY +#define FADESTEP 0x10 /* Nb steps for the fading effect */ +#define STARTFADE (0x06*FADESTEP) /* Initial value for the fading effect */ + +#define CLOSED 0x00 +#define OPENING 0x01 +#define OPENED 0x02 +#define CLOSING 0x03 + +static uint8_t time = 0; /* Global "time" value (counter) */ +uint8_t doorstate = 0; /* State of the door (OPENED, CLOSED...) */ +uint8_t doorpos = 0; /* Current position in the door animation */ +static uint8_t color = 0; /* Current color for fading effect */ +uint8_t sframe = 0; /* Current frame of the sprite */ +fixed bposx, bposy; /* Background position (fixed point) */ +fixed bspx, bspy; /* Background speed (fixed point) */ +fixed wposx, wposy; /* Window position (fixed point) */ +fixed wspx, wspy; /* Window speed (fixed point) */ +fixed sposx, sposy; /* Sprite position (fixed point) */ +fixed sspx, sspy; /* Sprite speed (fixed point) */ + +void fade(); +void scroll(); +void door(); +void animate_sprite(); +void tile_sprite(); +void place_sprite(); + +/* Fade the screen (off and on) */ +void fade() +{ + if(color == 0) + return; + switch(color) + { + case STARTFADE: + case STARTFADE-4*FADESTEP: + BGP_REG = 0xF9U; + break; + case STARTFADE-FADESTEP: + case STARTFADE-3*FADESTEP: + BGP_REG = 0xFEU; + break; + case STARTFADE-2*FADESTEP: + BGP_REG = 0xFFU; + break; + case STARTFADE-5*FADESTEP: + BGP_REG = 0xE4U; + break; + } + color--; +} + +/* Scroll the background, the window and the sprite */ +void scroll() +{ + /* Update background */ + bposx.w += bspx.w; + bposy.w += bspy.w; + SCX_REG = bposx.b.h; + SCY_REG = bposy.b.h; + + /* Update window */ + wposx.w += wspx.w ; + wposy.w += wspy.w ; + /* X position */ + if(wposx.b.h >= MAXWINX) { + wposx.b.h = MAXWINX; + /* Invert speed */ + wspx.w = -(int16_t)wspx.w; + } else if(wposx.b.h <= MINWINX) { + wposx.b.h = MINWINX; + /* Invert speed */ + wspx.w = -(int16_t)wspx.w; + } + WX_REG = wposx.b.h; + /* Y position */ + if(wposy.b.h >= MAXWINY) { + wposy.b.h = MAXWINY; + /* Invert speed */ + wspy.w = -(int16_t)wspy.w; + } else if(wposy.b.h <= MINWINY) { + wposy.b.h = MINWINY; + /* Invert speed */ + wspy.w = -(int16_t)wspy.w; + } + WY_REG = wposy.b.h; + + /* Update sprite */ + sposx.w += sspx.w; + sposy.w += sspy.w; + place_sprite(); +} + +/* Open and close the door */ +void door() +{ + if(doorstate == OPENING) { + doorpos++; + /* Draw the door in the window */ + set_win_tiles(2, 2, 12, 6, (unsigned char*)film[doorpos]); + if(doorpos == NBDFRAMES) + doorstate = OPENED; + } else if(doorstate == CLOSING) { + doorpos--; + /* Draw the door in the window */ + set_win_tiles(2, 2, 12, 6, (unsigned char*)film[doorpos]); + if(doorpos == 0) + doorstate = CLOSED; + } +} + +/* Animate sprite */ +void animate_sprite() +{ + if((time&0x07) == 0) { + sframe++; + if(sframe == NBSFRAMES) + sframe = 0; + tile_sprite(); + } +} + +/* Set sprite tiles */ +void tile_sprite() +{ + uint8_t s; + + s = sframe<<1; + set_sprite_tile(0, earth_tiles[s]); + set_sprite_tile(1, earth_tiles[s+1]); +} + +/* Place sprite */ +void place_sprite() +{ + move_sprite(0, sposx.b.h, sposy.b.h); + move_sprite(1, sposx.b.h+8, sposy.b.h); +} + +void main() +{ + uint8_t i, j; + + disable_interrupts(); + DISPLAY_OFF; + LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_WINON | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON; + /* + * LCD = Off + * WindowBank = 0x9C00 + * Window = On + * BG Chr = 0x8800 + * BG Bank = 0x9800 + * OBJ = 8x16 + * OBJ = On + * BG = On + */ + + doorstate = CLOSED; + + /* Set palettes */ + BGP_REG = OBP0_REG = OBP1_REG = 0xE4U; + + /* Initialize the background */ + set_bkg_data(0xFC, 0x04, std_data); + set_bkg_data(0x00, 0x2D, bkg_data); + /* + * Draw the background + * + * Width = 0x100 = 0x20 * 8 + * Height = 0x100 = 0x20 * 8 + */ + for(i = 0; i < 32; i+=8) + for(j = 0; j < 32; j+=8) + set_bkg_tiles(i, j, 8, 8, bkg_tiles); + bposx.w = 0; + SCX_REG = 0; + bposy.w = 0; + SCY_REG = 0; + bspx.w = 0xFF00; + bspy.w = 0x0080; + + /* Initialize the window */ + set_win_data(0x80, 0x21, frame_data); + /* + * Draw the frame in the window + * + * Width = 0x80 = 0x10 * 8 + * Height = 0x50 = 0x0A * 8 + */ + set_win_tiles(0, 0, 16, 10, frame_tiles); + /* + * Draw the door in the window + * + * Width = 0x60 = 0x20 * 12 + * Height = 0x30 = 0x20 * 6 + */ + set_win_tiles(2, 2, 12, 6, door1_tiles); + wposx.b.h = MAXWNDPOSX; + wposx.b.l = 0; + WX_REG = MAXWNDPOSX; + wposy.b.h = MAXWNDPOSY; + wposy.b.l = 0; + WY_REG = MAXWNDPOSY; + wspx.w = 0xFF80; + wspy.w = 0xFFC0; + + /* Initialize the sprite */ + set_sprite_data(0x00, 0x1C, earth_data); + set_sprite_prop(0, 0x00); + set_sprite_prop(1, 0x00); + sframe = 0; + sposx.w = 0x1000; + sposy.w = 0x1000; + sspx.w = 0x0040; + sspy.w = 0x0040; + tile_sprite(); + place_sprite(); + + DISPLAY_ON; + enable_interrupts(); + + while(1) { + /* Skip four VBLs (slow down animation) */ + for(i = 0; i < 4; i++) + wait_vbl_done(); + time++; + fade(); + door(); + scroll(); + animate_sprite(); + i = joypad(); + if(i & J_B) { + if(i & J_UP) + bspy.w -= 0x0010; + if(i & J_DOWN) + bspy.w += 0x0010; + if(i & J_LEFT) + bspx.w -= 0x0010; + if(i & J_RIGHT) + bspx.w += 0x0010; + } else if(i & J_A) { + if(i & J_UP) + wspy.w -= 0x0010; + if(i & J_DOWN) + wspy.w += 0x0010; + if(i & J_LEFT) + wspx.w -= 0x0010; + if(i & J_RIGHT) + wspx.w += 0x0010; + } else { + if(i & J_SELECT) + color = STARTFADE; + if(i & J_START) + if(doorstate == CLOSED) { + doorstate = OPENING; + doorpos = 0; + } else if(doorstate == OPENED) { + doorstate = CLOSING; + doorpos = NBDFRAMES; + } + if(i & J_UP) + sspy.w -= 0x0010; + if(i & J_DOWN) + sspy.w += 0x0010; + if(i & J_LEFT) + sspx.w -= 0x0010; + if(i & J_RIGHT) + sspx.w += 0x0010; + } + } +} diff --git a/gbdk-lib/examples/ap/gb-dtmf/Makefile b/gbdk-lib/examples/ap/gb-dtmf/Makefile @@ -0,0 +1,24 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = gb-dtmf.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +%.s: %.c + $(CC) -S -o $@ $< + +%.o: %.c + $(CC) -c -o $@ $< + +%.o: %.s + $(CC) -c -o $@ $< + +%.pocket: %.o + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm diff --git a/gbdk-lib/examples/ap/gb-dtmf/brk_btn.c b/gbdk-lib/examples/ap/gb-dtmf/brk_btn.c @@ -0,0 +1,41 @@ +/* + + BREAK_BTN.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 8 + + This file was generated by GBTD v0.5 + +*/ + +/* Start of tile array. */ +const unsigned char break_btn[] = +{ + 0x00,0x00,0x00,0x00,0x3F,0x00,0x3F,0x00, + 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00, + 0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0x01,0x00,0x03,0xFC,0x03,0xFC,0x03, + 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03, + 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00, + 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03, + 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03, + 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00, + 0x3F,0x00,0x3F,0x00,0x00,0x3F,0x00,0x7F, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0x00,0xFF,0x00,0xFF, + 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03, + 0xFC,0x03,0xFC,0x03,0x00,0xFF,0x00,0xFF +}; + +/* End of BREAK_BTN.C */ diff --git a/gbdk-lib/examples/ap/gb-dtmf/brk_btn.gbr b/gbdk-lib/examples/ap/gb-dtmf/brk_btn.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/gb-dtmf/cursor.c b/gbdk-lib/examples/ap/gb-dtmf/cursor.c @@ -0,0 +1,39 @@ +/* + + CURSOR.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Counter : None. + Tile size : 16 x 16 + Tiles : 0 to 1 + + This file was generated by GBTD v0.5 + +*/ + +/* Start of tile array. */ +const unsigned char cursor_data[] = +{ + 0x06,0x06,0x09,0x09,0x09,0x09,0x09,0x0F, + 0x09,0x0F,0x69,0x6F,0x19,0x3F,0x59,0x7F, + 0x49,0x7F,0x49,0x7F,0x40,0x7F,0x40,0x7F, + 0x20,0x3F,0x10,0x1F,0x08,0x0F,0x0F,0x0F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xA8,0xA8,0x54,0xFC, + 0x54,0xFC,0x54,0xFC,0x04,0xFC,0x04,0xFC, + 0x08,0xF8,0x10,0xF0,0x20,0xE0,0xE0,0xE0, + 0x00,0x00,0x06,0x06,0x09,0x09,0x09,0x0F, + 0x09,0x0F,0x69,0x6F,0x19,0x3F,0x59,0x7F, + 0x49,0x7F,0x49,0x7F,0x40,0x7F,0x40,0x7F, + 0x20,0x3F,0x10,0x1F,0x08,0x0F,0x0F,0x0F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xA8,0xA8,0x54,0xFC, + 0x54,0xFC,0x54,0xFC,0x04,0xFC,0x04,0xFC, + 0x08,0xF8,0x10,0xF0,0x20,0xE0,0xE0,0xE0 +}; + +/* End of CURSOR.C */ diff --git a/gbdk-lib/examples/ap/gb-dtmf/cursor.gbr b/gbdk-lib/examples/ap/gb-dtmf/cursor.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.c b/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.c @@ -0,0 +1,123 @@ +/* + + DTMF_LCD.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Counter : None. + Tile size : 8 x 16 + Tiles : 0 to 24 + + This file was generated by GBTD v0.5 + +*/ + +/* Start of tile array. */ +const unsigned char dtmf_lcd[] = +{ + 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x63,0x63,0x00,0x00, + 0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x02,0x7F,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x63,0x03,0x3C,0x00, + 0x3C,0x00,0x63,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02, + 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E, + 0x3E,0x3E,0x63,0x60,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E, + 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E, + 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02, + 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E, + 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E, + 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x00, + 0x3E,0x00,0x63,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02, + 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E, + 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E, + 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E, + 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x63,0x3E,0x00, + 0x3E,0x20,0x7F,0x60,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E, + 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x20, + 0x3E,0x20,0x63,0x60,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x02,0x7F,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E, + 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E, + 0x00,0x00,0x36,0x36,0x36,0x36,0x36,0x36, + 0x36,0x36,0x7F,0x7F,0x7F,0x7F,0x36,0x36, + 0x36,0x36,0x7F,0x7F,0x7F,0x7F,0x36,0x36, + 0x36,0x36,0x36,0x36,0x36,0x36,0x00,0x00, + 0x00,0x00,0x00,0x00,0x2A,0x2A,0x6B,0x6B, + 0x6B,0x6B,0x6B,0x6B,0x3E,0x3E,0x1C,0x1C, + 0x3E,0x3E,0x6B,0x6B,0x6B,0x6B,0x6B,0x6B, + 0x2A,0x2A,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3E,0x00,0x7F,0x00,0x63,0x00,0x63,0x00, + 0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00, + 0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00, + 0x63,0x00,0x63,0x00,0x7F,0x00,0x3E,0x00, + 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E, + 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03, + 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x22,0x7F,0x63,0x77,0x77,0x77,0x77, + 0x77,0x77,0x77,0x77,0x6B,0x6B,0x2A,0x2A, + 0x2A,0x2A,0x6B,0x6B,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x63,0x3E,0x22, + 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x22, + 0x3E,0x22,0x63,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E, + 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x63,0x60,0x3F,0x27, + 0x3F,0x27,0x63,0x63,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x3E, + 0x3E,0x3E,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x67,0x67,0x67,0x67,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x0C,0x0C,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E, + 0x0C,0x0C,0x04,0x04,0x08,0x08,0x00,0x00, + 0x3E,0x3E,0x7E,0x7E,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E, + 0x3E,0x3E,0x63,0x60,0x63,0x60,0x63,0x60, + 0x63,0x60,0x63,0x60,0x7F,0x60,0x3E,0x20 +}; + +/* End of DTMF_LCD.C */ diff --git a/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.gbr b/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.c b/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.c @@ -0,0 +1,41 @@ +/* + + FRAME_LCD.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 8 + + This file was generated by GBTD v0.5 + +*/ + +/* Start of tile array. */ +const unsigned char frame_lcd[] = +{ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F, + 0x00,0x1F,0x00,0x18,0x00,0x18,0x00,0x18, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, + 0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8, + 0x00,0xF8,0x00,0x18,0x00,0x18,0x00,0x18, + 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18, + 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18, + 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18, + 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x1F, + 0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, + 0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xF8, + 0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +/* End of FRAME_LCD.C */ diff --git a/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.gbr b/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/gb-dtmf/gb-dtmf.c b/gbdk-lib/examples/ap/gb-dtmf/gb-dtmf.c @@ -0,0 +1,715 @@ +/* ---------------------------------------- */ +/* GB-DTMF Ver1.0 */ +/* by */ +/* Osamu Ohashi */ +/* ---------------------------------------- */ + +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +/* BG data */ +#include "frm_lcd.c" /* Back ground pattern */ +#include "brk_btn.c" /* button image when broken */ +#include "prs_btn.c" /* button image when pressed */ + +#include "dtmf_lcd.c" /* LCD characters */ + +/* Sprite data */ +#include "key_num.c" /* Sprite pattern for each key pad */ +#include "cursor.c" /* cursor pattern */ + +/* + usage of BG data + file name number of BG type of matrix aount + ------------------------------------------------- + frame_lcd.c 9 8 x 8 9 + break_btn.c 9 8 x 8 9 + press_btn.c 9 8 x 8 9 + dtmf_lcd.c 25 8 x 16 50 + ------------------------------------------------ + total 77 + + + usage of OBJ data + file name number of obj type of matrix amount + -------------------------------------------------- + key_num.c 23 8 x 8 23 + cursor.c 2 16 x 16 8 + -------------------------------------------------- + total 31 +*/ + + +/* display */ +#define TITLE " GB-DTMF BY 05AMU " + +#define OFFSET 27U +#define KEY_STEP 24U /* Key matrix size as 24 x 24 */ +#define START_CURSOR_X 24U /* CURSOR position */ +#define START_CURSOR_Y 72U + +#define LCD_X 1U /* start position of X */ +#define LCD_Y 2U /* start position of Y */ +#define LCD_WIDTH 18U /* Horizontal size of LCD */ +#define LCD_HIGHT 2U /* Vertical Size of LCD */ + + +#define ON 1 +#define OFF 0 + +/* DTMF */ +#define DTMF_ON 100UL /* Tone on time */ +#define DTMF_OFF 100UL /* Tone off time */ + +#define MAX_DTMF 30 /* Maximum length of DTMF strings */ + +/* + Frequency setting +*/ +/* + We have to calculate the frequency as followin formula + + DTMF has two set frequency, we have to decide Row & Column + with each digit('0','1','2'...) +*/ + +#define C1 0x94U /* 1209Hz, 1213Hz */ +#define C2 0x9EU /* 1336Hz, 1337Hz */ +#define C3 0xA7U /* 1477Hz, 1472Hz */ +#define C4 0xB0U /* 1633Hz, 1638Hz */ + +#define R1 0x44U /* 697Hz, 697Hz */ +#define R2 0x56U /* 770Hz, 770Hz */ +#define R3 0x66U /* 852Hz, 851Hz */ +#define R4 0x75U /* 941Hz, 942Hz */ + +const unsigned char row[4] = {R1,R2,R3,R4}; /* DTMF frequency strage of Row */ +const unsigned char col[4] = {C1,C2,C3,C4}; /* DTMF frequency strage of Col */ + +/* It is possible to set up initial screen by each BG data. */ +const unsigned char dtmf_tile[] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, + 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, + 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, + + 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11, + 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14, + 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17, + + 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11, + 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14, + 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17, + + 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11, + 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14, + 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17, + + 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,10,10,10,11, + 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,13,13,13,14, + 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,16,16,16,17, + + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 +}; + +/* + Button image + Normal buttons are created by 3tiles x 3tiles(24pixels x 24pixels) + Dialing button is created by 6tiles x 3tiles(48pixels x 24pixels) +*/ +const unsigned char break_tile[] = { + 9,10,11, + 12,13,14, + 15,16,17 +}; + +const unsigned char dialing_break[] = { + 9,10,10,10,10,11, + 12,13,13,13,13,14, + 15,16,16,16,16,17 +}; + +const unsigned char press_tile[] = { + 18,19,20, + 21,22,23, + 24,25,26 +}; + + +const unsigned char dialing_press[] = { + 18,19,19,19,19,20, + 21,22,22,22,22,23, + 24,25,25,25,25,26 +}; + +/* + LCD image at initial & AC +*/ +const unsigned char init_disp[] = { + 59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59, + 60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60 +}; + +const char pad[4][6] = { /* DTMF Pad assign */ + {'1','2','3','A','%','P'}, + {'4','5','6','B','-','F'}, + {'7','8','9','C',',','?'}, + {'*','0','#','D','s','s'} +}; + +unsigned char disp_tile[MAX_DTMF * 2]; + +/* + Initialize for sound registers + ch1, ch2 are used for this routine. +*/ +void init_dial() +{ + + NR52_REG = 0x83U; + NR51_REG = 0x00U; + NR50_REG = 0x77U; + + NR24_REG = 0x87U; + NR22_REG = 0xffU; + NR21_REG = 0xbfU; + + NR14_REG = 0x87U; + NR12_REG = 0xffU; + NR11_REG = 0xbfU; + NR10_REG = 0x04U; +} + +/* sound engine for DTMF */ +void dialtone(uint16_t dtmf_on, uint16_t dtmf_off, char str[20]) +{ + uint8_t i = 0; + + while(str[i]){ + switch(str[i]){ + case '1': + NR13_REG = R1; + NR23_REG = C1; + break; + case '2': + NR13_REG = R1; + NR23_REG = C2; + break; + case '3': + NR13_REG = R1; + NR23_REG = C3; + break; + case 'A': + case 'a': + NR13_REG = R1; + NR23_REG = C4; + break; + case '4': + NR13_REG = R2; + NR23_REG = C1; + break; + case '5': + NR13_REG = R2; + NR23_REG = C2; + break; + case '6': + NR13_REG = R2; + NR23_REG = C3; + break; + case 'B': + case 'b': + NR13_REG = R2; + NR23_REG = C4; + break; + case '7': + NR13_REG = R3; + NR23_REG = C1; + break; + case '8': + NR13_REG = R3; + NR23_REG = C2; + break; + case '9': + NR13_REG = R3; + NR23_REG = C3; + break; + case 'C': + case 'c': + NR13_REG = R3; + NR23_REG = C4; + break; + case '*': + NR13_REG = R4; + NR23_REG = C1; + break; + case '0': + NR13_REG = R4; + NR23_REG = C2; + break; + case '#': + NR13_REG = R4; + NR23_REG = C3; + break; + case 'D': + case 'd': + NR13_REG = R4; + NR23_REG = C4; + break; + case ',': + delay(dtmf_on); /* keep on */ + delay(dtmf_off); /* keep off */ + + default: + NR51_REG = 0x00U; /* sound off */ + goto skip; + + } + NR24_REG = 0x87U; /* ch2 tips */ + NR51_REG = 0x33U; /* sound on */ + delay(dtmf_on); /* keep on */ + + NR51_REG = 0x00U; /* sound off */ + delay(dtmf_off); /* keep off */ + + skip: + i++; + } +} + + +/* Display looks like 7-SEGMENT LED */ +void disp_lcd(uint8_t len, char str[MAX_DTMF]) +{ + uint8_t i,j; + + j = len; + + i=0; + while(str[i]){ + if(str[i] >= '0'||'9' <= str[i]){ + disp_tile[i] = OFFSET + (str[i] - '0') * 2; + disp_tile[i+j] = OFFSET + (str[i] - '0') * 2 + 1; + } + switch(str[i]){ + case 'A': + disp_tile[i] = OFFSET + 10 * 2; + disp_tile[i+j] = OFFSET + 10 * 2 + 1; + break; + case 'B': + disp_tile[i] = OFFSET + 11 * 2; + disp_tile[i+j] = OFFSET + 11 * 2 + 1; + break; + case 'C': + disp_tile[i] = OFFSET + 12 * 2; + disp_tile[i+j] = OFFSET + 12 * 2 + 1; + break; + case 'D': + disp_tile[i] = OFFSET + 13 * 2; + disp_tile[i+j] = OFFSET + 13 * 2 + 1; + break; + case '#': + disp_tile[i] = OFFSET + 14 * 2; + disp_tile[i+j] = OFFSET + 14 * 2 + 1; + break; + case '*': + disp_tile[i] = OFFSET + 15 * 2; + disp_tile[i+j] = OFFSET + 15 * 2 + 1; + break; + case ' ': + disp_tile[i] = OFFSET + 16 * 2; + disp_tile[i+j] = OFFSET + 16 * 2 + 1; + break; + case 'Y': + disp_tile[i] = OFFSET + 17 * 2; + disp_tile[i+j] = OFFSET + 17 * 2 + 1; + break; + case 'M': + disp_tile[i] = OFFSET + 18 * 2; + disp_tile[i+j] = OFFSET + 18 * 2 + 1; + break; + case 'U': + disp_tile[i] = OFFSET + 19 * 2; + disp_tile[i+j] = OFFSET + 19 * 2 + 1; + break; + case 'G': + disp_tile[i] = OFFSET + 20 * 2; + disp_tile[i+j] = OFFSET + 20 * 2 + 1; + break; + case '-': + disp_tile[i] = OFFSET + 21 * 2; + disp_tile[i+j] = OFFSET + 21 * 2 + 1; + break; + case 'T': + disp_tile[i] = OFFSET + 22 * 2; + disp_tile[i+j] = OFFSET + 22 * 2 + 1; + break; + case ',': + disp_tile[i] = OFFSET + 23 * 2; + disp_tile[i+j] = OFFSET + 23 * 2 + 1; + break; + case 'F': + disp_tile[i] = OFFSET + 24 * 2; + disp_tile[i+j] = OFFSET + 24 * 2 + 1; + break; + case 'S': + disp_tile[i] = OFFSET + ('5' - '0') * 2; + disp_tile[i+j] = OFFSET + ('5' - '0') * 2 + 1; + break; + } + i++; + } +} + +/* clear display */ +void clr_disp() +{ + set_bkg_data(OFFSET, 50, dtmf_lcd); + set_bkg_tiles(LCD_X, LCD_Y, LCD_WIDTH, LCD_HIGHT, init_disp); +} + +/* + CAUTION: Don't display the NULL code +*/ +void disp(const char *str) +{ + uint8_t no, left_pos; + uint8_t i, start_ch, end_ch; + char work[MAX_DTMF]; + + clr_disp(); + + no = 0; + while(str[no]){ + no++; + } + + if(no >= LCD_WIDTH){ + start_ch = no - LCD_WIDTH; + end_ch = LCD_WIDTH; + } + else{ + start_ch = 0; + end_ch = no; + } + for(i = 0;i < end_ch;i++){ + work[i] = str[i+start_ch]; + } + work[end_ch] = 0x00; + + disp_lcd(end_ch, work); + + left_pos = 19 - end_ch; + set_bkg_tiles(left_pos, 2, end_ch, LCD_HIGHT, disp_tile); +} + +void press_button(uint8_t x, uint8_t y) +{ + if(x <= 3 && y <= 3){ + set_bkg_tiles(x * 3 + 1, y * 3 + 5, 3, 3, press_tile); + } + if((x == 4 || x == 5) && (y <= 2)){ + set_bkg_tiles(x * 3 + 2, y * 3 + 5, 3, 3, press_tile); + } + if((x == 4 || x == 5) && (y == 3)){ + set_bkg_tiles(14, 14, 6, 3, dialing_press); + } +} + +void break_button(uint8_t x, uint8_t y) +{ + if(x <= 3 && y <= 3){ + set_bkg_tiles(x * 3 + 1, y * 3 + 5, 3, 3, break_tile); + } + if((x == 4 || x == 5) && (y <= 2)){ + set_bkg_tiles(x * 3 + 2, y * 3 + 5, 3, 3, break_tile); + } + if((x == 4 || x == 5) && (y == 3)){ + set_bkg_tiles(14, 14, 6, 3, dialing_break); + } +} + + +void init_key() +{ + uint8_t key_x, key_y, i; + + /* To make numeric KeyPad */ + set_sprite_data(0, 24, key_num); + + /* key pad 1 - 3 */ + key_y = KEY_STEP + 40; + for(i = 1;i <= 3;i++){ + key_x = i * KEY_STEP; + set_sprite_tile(i, i); + move_sprite(i, key_x, key_y); + } + + /* key pad 4 - 6 */ + key_y = KEY_STEP * 2 + 40; + for(i = 4;i <= 6;i++){ + key_x = (i - 3) * KEY_STEP; + set_sprite_tile(i, i); + move_sprite(i, key_x, key_y); + } + + /* key pad 7 - 9 */ + key_y = KEY_STEP * 3 + 40; + for(i = 7;i <= 9;i++){ + key_x = (i - 6) * KEY_STEP; + set_sprite_tile(i, i); + move_sprite(i, key_x, key_y); + } + + /* key pad 'A' - 'D' */ + key_x = KEY_STEP * 4; + for(i = 0;i <= 3;i++){ + key_y = (i+1) * KEY_STEP + 40; + set_sprite_tile(i+10, i+10); + move_sprite(i+10, key_x, key_y); + } + + /* key pad '*', '0', '#' */ + set_sprite_tile(15, 15); + move_sprite(15, KEY_STEP * 1, KEY_STEP * 4 + 40U); + set_sprite_tile(0, 0); + move_sprite(0, KEY_STEP * 2, KEY_STEP * 4 + 40U); + set_sprite_tile(14, 14); + move_sprite(14, KEY_STEP * 3, KEY_STEP * 4 + 40U); + + /* func left */ + key_x = KEY_STEP * 5 + 8U; + for(i = 0;i <= 2;i++){ + key_y = (i+1) * KEY_STEP + 40; + set_sprite_tile(i+16, i+16); + move_sprite(i+16, key_x, key_y); + } + + /* func right */ + key_x = KEY_STEP * 6 + 8U; + for(i = 0;i <= 2;i++){ + key_y = (i+1) * KEY_STEP + 40; + set_sprite_tile(i+19, i+19); + move_sprite(i+19, key_x, key_y); + } + + /* dialing button */ + key_x = KEY_STEP * 5 + 20U; + key_y = KEY_STEP * 4 + 40U; + set_sprite_tile(22, 22); + move_sprite(22, key_x, key_y); +} + +void init_background() +{ + /* Initialize the background */ + set_bkg_data( 0, 9, frame_lcd); + set_bkg_data( 9, 9, break_btn); + set_bkg_data(18, 9, press_btn); + + set_bkg_tiles(0, 0, 20, 18, dtmf_tile); +} + +void init_cursor() +{ + uint8_t i; + + /* Setup the cursor data*/ + set_sprite_data(23, 8, cursor_data); + + for(i = 23;i <= 30;i++){ + set_sprite_tile(i, i); + } +} + +void move_cursor(uint8_t x, uint8_t y) +{ + move_sprite(23, x, y); + move_sprite(24, x, y+8); + move_sprite(25, x+8, y); + move_sprite(26, x+8, y+8); +} + +void main() +{ + uint8_t key1, key2, i, j, pos_x, pos_y, ch_pos; + uint8_t non_flick = OFF; + uint16_t on_time, off_time; + + char str[MAX_DTMF]; + char str_ms[10]; + + /* PENDING: sdcc is broken and needs this to be initalised. */ + key2 = 0; + + /* default dialling time setting */ + on_time = DTMF_ON; + off_time = DTMF_OFF; + + disable_interrupts(); + + SPRITES_8x8; /* sprites are 8x8 */ + + init_dial(); + + init_background(); + + init_key(); + + init_cursor(); + + disp(TITLE); + + SHOW_BKG; + SHOW_SPRITES; + DISPLAY_ON; + + enable_interrupts(); + + i = j = 0; + + ch_pos = 0; + + while(1) { + wait_vbl_done(); + key1 = joypad(); + + if(key1 != key2){ + pos_x = i * KEY_STEP + START_CURSOR_X; + pos_y = j * KEY_STEP + START_CURSOR_Y; + move_cursor(pos_x, pos_y); + } + + if(key2 & J_A){ + if(key1 & J_A){ + /* value set for each sound reg only numeric key pad*/ + if(i <= 3 && j <= 3){ + /* frequncy register set up for DTMF */ + NR13_REG = row[i]; + NR23_REG = col[j]; + NR24_REG = 0x87U; + + /* sound output on */ + NR51_REG = 0x33U; + } + + /* '?' button */ + /* appear the title during press A button */ + if(i == 5 && j == 0 && !non_flick){ + disp(TITLE); + non_flick = ON; + } + + /* incremental button */ + /* decremental button */ + /* appear the delay during press A button */ + if(i == 5 && (j == 1 || j == 2) && !non_flick){ + sprintf(str_ms, "%u MS", on_time); + disp(str_ms); + non_flick = ON; + } + } + else{ + /* sound output off */ + NR51_REG = 0x00U; + + break_button(i, j); + + /* '?' button */ + /* incremental button */ + /* decremental button */ + /* return to normal display at release the A button */ + if(i == 5 && (j == 0 || j == 1 || j == 2)){ + non_flick = OFF; + if(ch_pos == 0) + clr_disp(); + else + disp(str); + } + } + } + else{ + if(key1 & J_A){ + /* button display handle */ + press_button(i, j); + + /* numeric key pad handling */ + if(i <= 3 && j <= 3){ + /* string length check */ + if(ch_pos < MAX_DTMF-1){ + str[ch_pos] = pad[j][i]; + ch_pos++; + str[ch_pos] = 0x00; + disp(str); + } + } + + /* ',' button */ + if(i == 4 && j == 2){ + /* string length check */ + if(ch_pos < MAX_DTMF-1){ + str[ch_pos] = pad[j][i]; + ch_pos++; + str[ch_pos] = 0x00; + disp(str); + } + } + + /* all clear button */ + if(i == 4 && j == 0){ + ch_pos = 0x00; + strcpy(str,""); + clr_disp(); + } + + /* delete button */ + if(i == 4 && j == 1){ + if(ch_pos > 0){ + ch_pos--; + str[ch_pos] = 0x00; + if(ch_pos == 0) + clr_disp(); + else + disp(str); + } + } + + /* incremental button */ + if(i == 5 && j == 1){ + if(on_time >= DTMF_ON / 2){ + on_time = on_time - 10; + off_time = off_time - 10; + } + } + + /* decremental button */ + if(i == 5 && j == 2){ + if(on_time <= DTMF_ON * 2){ + on_time = on_time + 10; + off_time = off_time + 10; + } + } + + /* dialing button */ + if((i==4 || i==5) && j==3){ + dialtone(on_time, off_time, str); + } + } + } + if(!(key1 & J_A)){ + if((key1 & J_UP) && !(key2 & J_UP) && j > 0) + j--; + else if((key1 & J_DOWN) && !(key2 & J_DOWN) && j < 3) + j++; + + if((key1 & J_LEFT) && !(key2 & J_LEFT) && i > 0) + i--; + else if((key1 & J_RIGHT) && !(key2 & J_RIGHT) && i < 5) + i++; + } + key2 = key1; + } +} diff --git a/gbdk-lib/examples/ap/gb-dtmf/key_num.c b/gbdk-lib/examples/ap/gb-dtmf/key_num.c @@ -0,0 +1,69 @@ +/* + + KEY_NUM.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 22 + + This file was generated by GBTD v0.5 + +*/ + +/* Start of tile array. */ +const unsigned char key_num[] = +{ + 0xFF,0x3C,0xFF,0x7E,0xFF,0x66,0xFF,0x66, + 0xFF,0x66,0xFF,0x66,0xFF,0x7E,0xFF,0x3C, + 0xFF,0x18,0xFF,0x38,0xFF,0x38,0xFF,0x18, + 0xFF,0x18,0xFF,0x18,0xFF,0x18,0xFF,0x18, + 0xFF,0x3C,0xFF,0x66,0xFF,0x6E,0xFF,0x1C, + 0xFF,0x38,0xFF,0x70,0xFF,0x7E,0xFF,0x7E, + 0xFF,0x7C,0xFF,0x7E,0xFF,0x06,0xFF,0x3E, + 0xFF,0x3E,0xFF,0x06,0xFF,0x7E,0xFF,0x7C, + 0xFF,0x0C,0xFF,0x1C,0xFF,0x3C,0xFF,0x6C, + 0xFF,0x6E,0xFF,0x7E,0xFF,0x0C,0xFF,0x0C, + 0xFF,0x7C,0xFF,0x7C,0xFF,0x60,0xFF,0x7C, + 0xFF,0x06,0xFF,0x06,0xFF,0x7E,0xFF,0x7C, + 0x3C,0x3C,0x62,0x62,0x60,0x60,0x7C,0x7C, + 0x7E,0x7E,0x62,0x62,0x62,0x62,0x3C,0x3C, + 0x7E,0x7E,0x06,0x06,0x06,0x06,0x0C,0x0C, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x3C,0x3C,0x66,0x66,0x66,0x66,0x3C,0x3C, + 0x7E,0x7E,0x66,0x66,0x66,0x66,0x3C,0x3C, + 0x3C,0x3C,0x7E,0x7E,0x46,0x46,0x46,0x46, + 0x3E,0x3E,0x06,0x06,0x46,0x46,0x3C,0x3C, + 0x3C,0x3C,0x66,0x66,0x66,0x66,0x7E,0x7E, + 0x7E,0x7E,0x66,0x66,0x66,0x66,0x66,0x66, + 0x7E,0x7E,0x7F,0x7F,0x41,0x41,0x7E,0x7E, + 0x7F,0x7F,0x41,0x41,0x7F,0x7F,0x7E,0x7E, + 0x3C,0x3C,0x7E,0x7E,0xC2,0xC2,0xC0,0xC0, + 0xC0,0xC0,0xC2,0xC2,0x7E,0x7E,0x3C,0x3C, + 0x7E,0x7E,0x7F,0x7F,0x63,0x63,0x63,0x63, + 0x63,0x63,0x63,0x63,0x7F,0x7F,0x7E,0x7E, + 0x36,0x36,0x7F,0x7F,0x7F,0x7F,0x36,0x36, + 0x7F,0x7F,0x7F,0x7F,0x36,0x36,0x36,0x36, + 0xC3,0xC3,0x66,0x66,0x3C,0x3C,0xFF,0xFF, + 0xFF,0xFF,0x3C,0x3C,0x66,0x66,0xC3,0xC3, + 0xF0,0xF0,0x90,0x90,0xF0,0xF0,0x90,0x90, + 0x97,0x97,0x08,0x08,0x08,0x08,0x07,0x07, + 0x0C,0x0C,0x1C,0x1C,0x3C,0x3C,0x7C,0x7C, + 0x7C,0x7C,0x3C,0x3C,0x1C,0x1C,0x0C,0x0C, + 0x00,0x00,0x18,0x18,0x3C,0x3C,0x3C,0x3C, + 0x1C,0x1C,0x0C,0x0C,0x38,0x38,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x02,0x02,0x1C,0x1C, + 0x18,0x18,0x00,0x00,0x18,0x18,0x18,0x18, + 0x00,0x00,0x18,0x18,0x3C,0x3C,0x7E,0x7E, + 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, + 0x7E,0x7E,0x3C,0x3C,0x18,0x18,0x00,0x00, + 0x12,0x12,0x34,0x34,0xF1,0xF1,0xF2,0xF2, + 0xF2,0xF2,0xF1,0xF1,0x34,0x34,0x12,0x12 +}; + +/* End of KEY_NUM.C */ diff --git a/gbdk-lib/examples/ap/gb-dtmf/key_num.gbr b/gbdk-lib/examples/ap/gb-dtmf/key_num.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/gb-dtmf/prs_btn.c b/gbdk-lib/examples/ap/gb-dtmf/prs_btn.c @@ -0,0 +1,41 @@ +/* + + PRESS_BTN.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 8 + + This file was generated by GBTD v0.5 + +*/ + +/* Start of tile array. */ +const unsigned char press_btn[] = +{ + 0x00,0xFF,0x00,0xFF,0x3F,0xC0,0x3F,0xC0, + 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0, + 0x00,0xFF,0x00,0xFF,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFE,0x00,0xFC,0xFC,0x00,0xFC,0x00, + 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00, + 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0, + 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00, + 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00, + 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0, + 0x3F,0xC0,0x3F,0xC0,0x00,0xC0,0x00,0x80, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00, + 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00, + 0xFC,0x00,0xFC,0x00,0x00,0x00,0x00,0x00 +}; + +/* End of PRESS_BTN.C */ diff --git a/gbdk-lib/examples/ap/gb-dtmf/prs_btn.gbr b/gbdk-lib/examples/ap/gb-dtmf/prs_btn.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/gbdecompress/Makefile b/gbdk-lib/examples/ap/gbdecompress/Makefile @@ -0,0 +1,33 @@ +# +# Simple Makefile that compiles all .c and .s files in the same folder +# + +# If you move this project you can change the directory +# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" +GBDK_HOME = ../../../ + +LCC = $(GBDK_HOME)bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +# You can uncomment the line below to turn on debug output +# LCC = $(LCC) -debug + +# You can set the name of the .pocket ROM file here +PROJECTNAME = gbdecompress + +BINS = $(PROJECTNAME).pocket +CSOURCES := $(wildcard *.c) +ASMSOURCES := $(wildcard *.s) + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link all source files in a single call to LCC +$(BINS): $(CSOURCES) $(ASMSOURCES) + $(LCC) -o $@ $(CSOURCES) $(ASMSOURCES) + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm *.noi + diff --git a/gbdk-lib/examples/ap/gbdecompress/Readme.md b/gbdk-lib/examples/ap/gbdecompress/Readme.md @@ -0,0 +1,8 @@ + +GBDecompress +============ + +Demonstrates using gbdecompress to load a compressed tile set into vram. + +The tileset was compressed during export from GBTD by checking the +GB-compress checkbox in the export settings panel. diff --git a/gbdk-lib/examples/ap/gbdecompress/main.c b/gbdk-lib/examples/ap/gbdecompress/main.c @@ -0,0 +1,41 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <gb/gbdecompress.h> +#include <stdbool.h> + +// Include graphics data +#include "monalisa_tiles_comp.h" +#include "monalisa_map.h" + +// The map tiles were exported from GBTD with compression enabled +// using this updated version of GBTD: https://github.com/untoxa/GBTD_GBMB +// Size was 4096 bytes -> 3493 bytes + +void main(void) +{ + // Decompress the map tiles into the background tile vram. + // + // Notice that the number of tiles isn't specified. The amount + // of data to decompress is embedded in the compressed data. + // + // Note: For non-compressed data the equivalent would be: set_bkg_data(0, 253u, monalisa_tiles) + // + gb_decompress_bkg_data(0, monalisa_tiles_comp); // first tile, pointer to comrpessed data + + // Now set the map and turn the background on + set_bkg_tiles(0,0, monalisa_mapWidth, monalisa_mapHeight, monalisa_mapPLN0); + SHOW_BKG; + + // Loop forever + while(1) { + + // Main loop processing goes here + + // Done processing, yield CPU and wait for start of next frame + wait_vbl_done(); + } +} + + + + diff --git a/gbdk-lib/examples/ap/gbdecompress/monalisa.gbm b/gbdk-lib/examples/ap/gbdecompress/monalisa.gbm Binary files differ. diff --git a/gbdk-lib/examples/ap/gbdecompress/monalisa_map.c b/gbdk-lib/examples/ap/gbdecompress/monalisa_map.c @@ -0,0 +1,66 @@ +/* + + MONALISA_MAP.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 20 x 18 + Tile set : monalisa_tiles.gbr + Plane count : 1 plane (8 bits) + Plane order : Planes are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define monalisa_mapWidth 20 +#define monalisa_mapHeight 18 +#define monalisa_mapBank 0 + +#define monalisa_map monalisa_mapPLN0 +const unsigned char monalisa_mapPLN0[] = +{ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02, + 0x03,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x06,0x07, + 0x08,0x09,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x0C,0x0D,0x0E, + 0x0F,0x10,0x11,0x12,0x00,0x00,0x00,0x00,0x00,0x00, + 0x13,0x14,0x00,0x00,0x00,0x00,0x15,0x16,0x00,0x17, + 0x18,0x19,0x1A,0x1B,0x1C,0x13,0x00,0x00,0x00,0x00, + 0x1D,0x1E,0x1F,0x20,0x21,0x00,0x22,0x23,0x24,0x25, + 0x26,0x27,0x1A,0x28,0x29,0x2A,0x2B,0x00,0x00,0x00, + 0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35, + 0x36,0x37,0x1A,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E, + 0x3F,0x40,0x41,0x41,0x42,0x43,0x44,0x45,0x46,0x47, + 0x48,0x49,0x1A,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50, + 0x51,0x52,0x41,0x53,0x54,0x55,0x56,0x57,0x58,0x59, + 0x5A,0x5B,0x1A,0x1A,0x5C,0x5D,0x5E,0x5F,0x60,0x61, + 0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x1A,0x69,0x6A, + 0x6B,0x6C,0x1A,0x1A,0x6D,0x6E,0x6F,0x70,0x71,0x72, + 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x1A,0x7A,0x7B, + 0x7C,0x7D,0x7E,0x1A,0x7F,0x80,0x81,0x82,0x83,0x84, + 0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E, + 0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98, + 0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xA0,0xA1,0x00, + 0x00,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA, + 0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0x00,0x00, + 0x00,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB, + 0xBC,0xBD,0xBE,0xBF,0xC0,0x1A,0xC1,0xC2,0xC3,0x00, + 0xC4,0xC5,0xC6,0xC7,0x1A,0x1A,0x1A,0xC8,0xC9,0xCA, + 0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4, + 0xD5,0xD6,0x1A,0x1A,0xD7,0xD8,0x1A,0xD9,0xDA,0xDB, + 0xDC,0xDD,0xDE,0xDF,0x1A,0xE0,0xE1,0xE2,0xE3,0xE4, + 0xE5,0x1A,0x1A,0xE6,0xE7,0xE8,0x1A,0xE9,0xEA,0xEB, + 0xEC,0xED,0xEE,0xEF,0xF0,0x1A,0x1A,0x1A,0xF1,0xF2, + 0x1A,0x1A,0x1A,0xF3,0xF4,0x1A,0x1A,0x1A,0xF5,0xF6, + 0xF7,0xF8,0xF9,0xFA,0xFB,0x1A,0x1A,0x1A,0x1A,0x1A, + 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0xFC +}; + +/* End of MONALISA_MAP.C */ diff --git a/gbdk-lib/examples/ap/gbdecompress/monalisa_map.h b/gbdk-lib/examples/ap/gbdecompress/monalisa_map.h @@ -0,0 +1,32 @@ +/* + + MONALISA_MAP.H + + Map Include File. + + Info: + Section : + Bank : 0 + Map size : 20 x 18 + Tile set : monalisa_tiles.gbr + Plane count : 1 plane (8 bits) + Plane order : Planes are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ +#ifndef __monalisa_map_h_INCLUDE +#define __monalisa_map_h_INCLUDE + +#define monalisa_mapWidth 20 +#define monalisa_mapHeight 18 +#define monalisa_mapBank 0 + +#define monalisa_map monalisa_mapPLN0 +extern const unsigned char monalisa_mapPLN0[]; + +#endif + +/* End of MONALISA_MAP.H */ diff --git a/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles.gbr b/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.c b/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.c @@ -0,0 +1,467 @@ +/* + + MONALISA_TILES_COMP.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : GB-Compress. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 252 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + +/* Start of tile array. */ +const unsigned char monalisa_tiles_comp[] = +{ + 0x1D,0x00,0xC1,0x02,0x01,0x8B,0xE0,0xFF, + 0xC3,0x10,0x2F,0x11,0xFF,0x8B,0xD0,0xFF, + 0xC2,0x0D,0xF2,0x54,0x8C,0xF0,0xFF,0xC2, + 0x00,0x00,0xE0,0x89,0xB1,0xFF,0xE9,0x01, + 0x02,0x01,0x02,0x07,0x08,0x07,0x02,0x0F, + 0x20,0x1F,0x6A,0x3F,0x82,0x7D,0xA1,0xFE, + 0xAB,0x54,0x01,0xFE,0xAF,0x50,0xAF,0xFF, + 0x0D,0xFF,0x2F,0xFF,0x81,0x7F,0x2A,0xFF, + 0xA0,0x5F,0x0A,0xFF,0xA8,0x57,0xFF,0xFF, + 0xDD,0x02,0xFF,0xD0,0x57,0xFF,0xFF,0xFF, + 0x5D,0xFF,0x3F,0xFF,0x15,0xFF,0xE0,0xF8, + 0xDA,0xFC,0xFF,0xFE,0xDF,0x08,0xFF,0x84, + 0x60,0xFF,0xCA,0x80,0x80,0x00,0x80,0xE0, + 0xD0,0xE0,0xE0,0xF0,0xF0,0xF8,0x8B,0x50, + 0xFF,0xD8,0x01,0x00,0x01,0x00,0x1A,0x0F, + 0x00,0x1F,0x09,0x3E,0x64,0x18,0xE6,0x38, + 0x0C,0x70,0xE8,0x70,0x50,0xE0,0x1E,0xE0, + 0xC0,0x00,0x80,0x8A,0x2B,0xFF,0xC5,0xD0, + 0x2F,0x45,0x00,0x2B,0x00,0x89,0x39,0xFF, + 0xCF,0xBF,0xFF,0x1D,0xFF,0x8F,0x7F,0x61, + 0x1F,0xC3,0x3F,0x79,0x07,0xBA,0x07,0x18, + 0x07,0x85,0x97,0xFF,0xC3,0x7F,0xFF,0xFF, + 0xFF,0x83,0x8C,0xFF,0xC5,0x5F,0xFF,0xF8, + 0xFC,0xFE,0xFC,0x02,0xFE,0x8C,0x80,0xFF, + 0xC0,0x40,0x83,0xFC,0xFF,0xC6,0x80,0x40, + 0x80,0xE0,0x80,0x80,0xC0,0x84,0x71,0xFF, + 0xC9,0x00,0x00,0x00,0x90,0x00,0x10,0x00, + 0xB3,0x00,0x51,0x8A,0xC1,0xFE,0xE3,0x05, + 0x00,0x3F,0x00,0x5F,0x00,0x02,0x01,0x02, + 0x01,0x04,0x03,0x06,0x01,0x07,0x0B,0x19, + 0x07,0x1B,0x07,0x1D,0x07,0xD8,0xE0,0xF4, + 0xC0,0xD8,0xE0,0x70,0xC0,0xD8,0xE0,0xB4, + 0xC0,0x98,0xE0,0x85,0xC0,0xFF,0x84,0xA6, + 0xFE,0x83,0xA2,0xFE,0xD2,0x00,0x00,0x00, + 0xB0,0x0F,0x5A,0x05,0xBC,0x03,0x1E,0x01, + 0xBD,0x02,0x55,0x00,0xAF,0x00,0x01,0x00, + 0x83,0x7C,0xFF,0xCB,0xBF,0xFF,0x9F,0x7F, + 0x0F,0xFF,0xEF,0x1F,0xCF,0x3F,0x67,0x1F, + 0x0F,0xFF,0xFF,0xCA,0xE0,0xF1,0xC0,0xFF, + 0xE0,0xF7,0xE0,0xE5,0xFA,0xEF,0xF0,0xFD, + 0xF2,0xFE,0xF1,0xC0,0x00,0x40,0x00,0xEE, + 0x00,0x45,0x00,0xFF,0x00,0x75,0x00,0xDF, + 0x20,0xFD,0x00,0x55,0xAA,0x77,0x80,0x9D, + 0xE2,0x0E,0xF1,0xE4,0xFB,0xCA,0xF5,0xE0, + 0xFF,0x0A,0xF5,0x7D,0x82,0xBD,0x40,0x5D, + 0xA2,0xBF,0x40,0x15,0xEA,0xBF,0x40,0x1D, + 0xE2,0xBF,0x40,0xD5,0xC0,0x00,0xD5,0x00, + 0x7F,0x80,0xF7,0x00,0xD5,0x2A,0xDF,0x00, + 0xFD,0x02,0x7B,0x04,0xA8,0x00,0x54,0x00, + 0xFE,0x00,0x83,0xC8,0xFF,0xC5,0xFF,0x00, + 0xC1,0x3E,0xBB,0x44,0x83,0xF0,0xFD,0xDB, + 0xC0,0x00,0xD0,0x00,0x5C,0xA0,0xF4,0x00, + 0xFC,0x00,0xDC,0x00,0x17,0x0F,0x1D,0x07, + 0x17,0x2F,0x2D,0x17,0x4B,0x3F,0x61,0x1F, + 0x4A,0x3F,0x65,0x1F,0x83,0x3C,0xFF,0xCB, + 0x8A,0xE0,0x01,0xC0,0x94,0xEB,0xAC,0xD0, + 0x84,0xFB,0x24,0xD9,0x85,0xF0,0xFE,0xFF, + 0x40,0x00,0x10,0xE0,0x70,0x00,0x98,0xE0, + 0x30,0xC0,0x00,0x00,0x04,0x00,0x3F,0x00, + 0x6F,0x10,0xC1,0x3E,0x8D,0x70,0xBC,0x63, + 0xB0,0x41,0xAB,0x00,0x45,0x00,0xFD,0x02, + 0xFE,0x01,0x0A,0xFF,0x60,0x1F,0x2A,0xFF, + 0x8B,0x74,0xCF,0x3F,0xEF,0x1F,0x0F,0xFF, + 0xA7,0x5F,0x8F,0xFF,0x27,0xDF,0x4F,0xBF, + 0x67,0x1F,0xF0,0xFF,0xFA,0xF5,0xF8,0xFF, + 0xC2,0xF8,0xF7,0xFA,0x42,0xFF,0xF8,0xC4, + 0xFF,0x47,0xB8,0x7F,0x80,0x83,0x58,0xFF, + 0xD7,0x05,0xFA,0x2B,0xD4,0x21,0xFE,0x0A, + 0xF5,0xDD,0x22,0xF7,0x00,0x7D,0x82,0xF7, + 0x00,0x5D,0xA2,0xFB,0x04,0xD1,0x2E,0xBA, + 0x45,0x85,0x60,0xFF,0xC2,0x40,0x00,0xE0, + 0x83,0xFC,0xFF,0xD2,0x00,0xD0,0x00,0xE0, + 0xFF,0xCB,0xF4,0xA0,0xFF,0x4A,0xF5,0xA0, + 0xFF,0x2A,0xD5,0x00,0xFF,0x7A,0x85,0x83, + 0x18,0xFF,0xE4,0x5D,0xA2,0xFF,0x00,0x11, + 0xEE,0xAF,0x50,0x1D,0xE2,0xAB,0x54,0x45, + 0xBA,0xFF,0x00,0xDD,0x22,0xFA,0x05,0x00, + 0xFF,0xAA,0x55,0xC0,0x3F,0x8A,0x75,0x51, + 0xAE,0xEB,0x14,0x20,0xFF,0xAA,0x55,0x00, + 0x84,0xD0,0xFF,0xFF,0x8A,0x75,0x74,0x88, + 0x68,0x90,0x46,0xB8,0xA7,0x58,0x89,0xFE, + 0x22,0xDD,0x08,0xFF,0x20,0xDF,0x1A,0x00, + 0x3C,0x00,0xD5,0x2A,0xFB,0x04,0x51,0xAE, + 0xB8,0x47,0x02,0xFF,0xA8,0x57,0x4F,0x3F, + 0x6D,0x1F,0xCF,0x3F,0x65,0x1F,0x4F,0xBF, + 0xAD,0x5F,0x0F,0xFF,0x05,0xFF,0xBA,0xC0, + 0x94,0xC0,0xAB,0xC0,0x80,0xC0,0xA0,0xC0, + 0x80,0xC0,0xA8,0xC0,0xC6,0xE0,0xC0,0xE8, + 0x00,0x40,0x00,0x68,0x8A,0x8F,0xFD,0xC5, + 0x18,0xE0,0xF4,0x00,0x7B,0x80,0x85,0x60, + 0xFF,0xC8,0xA0,0x00,0x40,0x00,0xF2,0x08, + 0x54,0x00,0xE8,0x84,0x10,0xFE,0xC5,0x05, + 0x00,0x03,0x00,0x01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0xDC,0xFB, + 0xCE,0xF9,0xFE,0xD3,0xFC,0xFA,0xFF,0xC3, + 0xFC,0xE6,0xF8,0x3C,0xC0,0x9A,0xE0,0xD4, + 0x84,0x72,0xF7,0xC4,0x7B,0x80,0x44,0x00, + 0xAA,0x86,0x90,0xF8,0x83,0x14,0xF7,0xC2, + 0xFF,0x00,0x54,0x84,0xF0,0xFF,0xC0,0xA0, + 0x86,0x07,0xF7,0xC2,0xBD,0x02,0x47,0x84, + 0x88,0xF8,0xC8,0x23,0x00,0x04,0x00,0x0B, + 0x00,0x01,0x00,0x7F,0x84,0x88,0xFF,0xD9, + 0x95,0x7F,0x0A,0xFF,0x88,0x7F,0x2E,0xFF, + 0x84,0x7F,0xFF,0xFF,0xCF,0xFF,0xFF,0xFF, + 0x07,0xFF,0x2F,0xFF,0x8D,0x7F,0x2F,0xFF, + 0x95,0x7F,0x89,0x74,0xFE,0x83,0xF8,0xFD, + 0xC5,0x5F,0xFF,0xAE,0xFF,0x06,0xFD,0x83, + 0xE8,0xFC,0xF7,0xE8,0xFF,0x2B,0xD4,0xA7, + 0xF8,0x03,0xFC,0x39,0xFE,0x1C,0xFF,0xBA, + 0xFF,0x02,0xFD,0x55,0xAA,0xF4,0x00,0xFF, + 0x00,0x17,0x00,0xF5,0x0A,0xFD,0x00,0x7C, + 0x83,0xD6,0x01,0xF8,0x07,0x5B,0x04,0xDD, + 0x22,0xDF,0x00,0x10,0xEF,0x7A,0x85,0x5C, + 0xA3,0xBE,0x41,0x14,0xEB,0xBA,0x45,0x00, + 0xFF,0xEA,0x15,0x83,0x78,0xF9,0xC5,0x24, + 0xFB,0x0E,0xF1,0xA4,0xFB,0x83,0x90,0xFD, + 0xC1,0xFE,0x01,0x85,0x90,0xFB,0x83,0xD4, + 0xFC,0x83,0x70,0xF9,0xC9,0x22,0xDD,0xAE, + 0xFF,0x00,0xFF,0xA8,0xFF,0x22,0xDD,0x83, + 0x98,0xFC,0x83,0xD4,0xFE,0x87,0x40,0xFD,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0xFA,0xC6,0xFF,0xFA,0xFF,0xD2,0xFD, + 0xA9,0xFE,0x83,0x10,0xFD,0x83,0x30,0xF9, + 0x83,0x98,0xFB,0xDA,0x28,0xD7,0xAD,0x02, + 0xD7,0x00,0x9D,0xE2,0x8B,0x74,0x25,0xFA, + 0x22,0xDD,0x03,0xFE,0x20,0xDF,0xA8,0xFF, + 0x42,0xFD,0xFA,0xFF,0x54,0xFF,0xFE,0x84, + 0x00,0xFA,0xC5,0x57,0xFF,0x44,0xBB,0x2F, + 0xD0,0x83,0xA8,0xF3,0xC1,0x05,0xFA,0x83, + 0xCC,0xF6,0xC9,0x02,0xFD,0x04,0xFB,0xAB, + 0x54,0x55,0xAA,0xBF,0x40,0x83,0x30,0xF5, + 0xCF,0x48,0xB7,0xAA,0x55,0x43,0xBF,0x29, + 0xD7,0x43,0xBF,0xD9,0x07,0x53,0xAF,0xF9, + 0x07,0x85,0xB0,0xFA,0x8B,0xC8,0xFB,0xC0, + 0x7F,0x86,0xA4,0xF7,0x83,0x80,0xF6,0xFF, + 0xF8,0xFF,0xFA,0xFF,0xF9,0xFF,0x82,0xFF, + 0x20,0xDF,0xA3,0xFF,0x09,0xF7,0xAA,0xFF, + 0x44,0xFF,0xEE,0xFF,0x44,0xFF,0x80,0xFF, + 0x0A,0xF5,0xA8,0xFF,0x82,0x7D,0x88,0xFF, + 0x02,0xFD,0x38,0xFF,0x52,0xFD,0x45,0xBA, + 0x7F,0x80,0x0D,0xF2,0xFA,0x05,0x01,0xFE, + 0xEA,0x15,0x84,0x7B,0xAA,0x55,0x6A,0x80, + 0xFF,0x00,0x5D,0xA2,0xBE,0x41,0x40,0xBF, + 0x83,0xAC,0xF5,0xC5,0x88,0x77,0x0F,0x00, + 0xFE,0x01,0x83,0x14,0xFA,0xCE,0x44,0xBB, + 0x98,0x67,0x08,0xFF,0x29,0xD7,0x0B,0xFF, + 0x42,0xBD,0x23,0xFF,0x07,0x84,0x00,0xF8, + 0x8B,0x08,0xFF,0x83,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6,0xFF,0xFF,0xED, + 0xFF,0xFF,0xFF,0x50,0x86,0x88,0xFF,0x83, + 0x64,0xF5,0xC6,0x81,0xFF,0xFE,0xFF,0x01, + 0xFF,0xA2,0x84,0x4C,0xF8,0xC2,0x50,0xFF, + 0xEA,0x83,0xFC,0xFF,0xC2,0xFF,0xD0,0xFF, + 0x00 +}; + +/* End of MONALISA_TILES_COMP.C */ diff --git a/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.h b/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.h @@ -0,0 +1,107 @@ +/* + + MONALISA_TILES_COMP.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : GB-Compress. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 252 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + +#ifndef __monalisa_tiles_comp_h_INCLUDE +#define __monalisa_tiles_comp_h_INCLUDE + +/* Bank of tiles. */ +#define monalisa_tiles_compBank 0 + +/* Super Gameboy palette 0 */ +#define monalisa_tiles_compSGBPal0c0 0 +#define monalisa_tiles_compSGBPal0c1 0 +#define monalisa_tiles_compSGBPal0c2 18432 +#define monalisa_tiles_compSGBPal0c3 749 + +/* Super Gameboy palette 1 */ +#define monalisa_tiles_compSGBPal1c0 6076 +#define monalisa_tiles_compSGBPal1c1 8935 +#define monalisa_tiles_compSGBPal1c2 6596 +#define monalisa_tiles_compSGBPal1c3 5344 + +/* Super Gameboy palette 2 */ +#define monalisa_tiles_compSGBPal2c0 6076 +#define monalisa_tiles_compSGBPal2c1 8935 +#define monalisa_tiles_compSGBPal2c2 6596 +#define monalisa_tiles_compSGBPal2c3 5344 + +/* Super Gameboy palette 3 */ +#define monalisa_tiles_compSGBPal3c0 6076 +#define monalisa_tiles_compSGBPal3c1 8935 +#define monalisa_tiles_compSGBPal3c2 6596 +#define monalisa_tiles_compSGBPal3c3 5344 + +/* Gameboy Color palette 0 */ +#define monalisa_tiles_compCGBPal0c0 4228 +#define monalisa_tiles_compCGBPal0c1 11627 +#define monalisa_tiles_compCGBPal0c2 20083 +#define monalisa_tiles_compCGBPal0c3 30653 + +/* Gameboy Color palette 1 */ +#define monalisa_tiles_compCGBPal1c0 6076 +#define monalisa_tiles_compCGBPal1c1 8935 +#define monalisa_tiles_compCGBPal1c2 6596 +#define monalisa_tiles_compCGBPal1c3 5344 + +/* Gameboy Color palette 2 */ +#define monalisa_tiles_compCGBPal2c0 6076 +#define monalisa_tiles_compCGBPal2c1 8935 +#define monalisa_tiles_compCGBPal2c2 6596 +#define monalisa_tiles_compCGBPal2c3 5344 + +/* Gameboy Color palette 3 */ +#define monalisa_tiles_compCGBPal3c0 6076 +#define monalisa_tiles_compCGBPal3c1 8935 +#define monalisa_tiles_compCGBPal3c2 6596 +#define monalisa_tiles_compCGBPal3c3 5344 + +/* Gameboy Color palette 4 */ +#define monalisa_tiles_compCGBPal4c0 6076 +#define monalisa_tiles_compCGBPal4c1 8935 +#define monalisa_tiles_compCGBPal4c2 6596 +#define monalisa_tiles_compCGBPal4c3 5344 + +/* Gameboy Color palette 5 */ +#define monalisa_tiles_compCGBPal5c0 6076 +#define monalisa_tiles_compCGBPal5c1 8935 +#define monalisa_tiles_compCGBPal5c2 6596 +#define monalisa_tiles_compCGBPal5c3 5344 + +/* Gameboy Color palette 6 */ +#define monalisa_tiles_compCGBPal6c0 6076 +#define monalisa_tiles_compCGBPal6c1 8935 +#define monalisa_tiles_compCGBPal6c2 6596 +#define monalisa_tiles_compCGBPal6c3 5344 + +/* Gameboy Color palette 7 */ +#define monalisa_tiles_compCGBPal7c0 6076 +#define monalisa_tiles_compCGBPal7c1 8935 +#define monalisa_tiles_compCGBPal7c2 6596 +#define monalisa_tiles_compCGBPal7c3 5344 +/* Start of tile array. */ +extern const unsigned char monalisa_tiles_comp[]; + +#endif + +/* End of MONALISA_TILES_COMP.H */ diff --git a/gbdk-lib/examples/ap/incbin/Makefile b/gbdk-lib/examples/ap/incbin/Makefile @@ -0,0 +1,60 @@ +# +# A Makefile that compiles all .c and .s files in "src" and "res" +# subdirectories and places the output in a "obj" subdirectory +# + +# If you move this project you can change the directory +# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" +GBDK_HOME = ../../../ + +LCC = $(GBDK_HOME)bin/lcc + +# You can set flags for LCC here +# For example, you can uncomment the line below to turn on debug output +LCCFLAGS = -mgbz80:ap -Wl-j -Wm-yS + +# You can set the name of the .pocket ROM file here +PROJECTNAME = Example + +SRCDIR = src +OBJDIR = obj +RESDIR = res +BINS = $(PROJECTNAME).pocket +CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c))) +ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s))) +OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o) + +all: prepare $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile .c files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.c + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# Compile .c files in "res/" to .o object files +$(OBJDIR)/%.o: $(RESDIR)/%.c + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# Compile .s assembly files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.s + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# If needed, compile .c files i n"src/" to .s assembly files +# (not required if .c is compiled directly to .o) +$(OBJDIR)/%.s: $(SRCDIR)/%.c + $(LCC) $(LCCFLAGS) -S -o $@ $< + +# Link the compiled object files into a .pocket ROM file +$(BINS): $(OBJS) + $(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS) + +prepare: + mkdir -p $(OBJDIR) + +clean: + rm -f *.pocket *.ihx *.cdb *.adb *.noi *.map *.sym + rm -rf $(OBJDIR) + diff --git a/gbdk-lib/examples/ap/incbin/Readme.md b/gbdk-lib/examples/ap/incbin/Readme.md @@ -0,0 +1,8 @@ + +An example project showing how to use 'incbin.h' to include binary files into C source files. + + +The 4 color .png files were exported to .bin format (2bpp gb) using the gimp plugin listed below. +There are many other tools which can also do the conversion. + +https://github.com/bbbbbr/gimp-rom-bin diff --git a/gbdk-lib/examples/ap/incbin/res/blanktile.bin b/gbdk-lib/examples/ap/incbin/res/blanktile.bin Binary files differ. diff --git a/gbdk-lib/examples/ap/incbin/res/blanktile.png b/gbdk-lib/examples/ap/incbin/res/blanktile.png Binary files differ. diff --git a/gbdk-lib/examples/ap/incbin/res/gbdk2020.bin b/gbdk-lib/examples/ap/incbin/res/gbdk2020.bin Binary files differ. diff --git a/gbdk-lib/examples/ap/incbin/res/gbdk2020.png b/gbdk-lib/examples/ap/incbin/res/gbdk2020.png Binary files differ. diff --git a/gbdk-lib/examples/ap/incbin/res/gbdk2020_map.bin b/gbdk-lib/examples/ap/incbin/res/gbdk2020_map.bin Binary files differ. diff --git a/gbdk-lib/examples/ap/incbin/src/main.c b/gbdk-lib/examples/ap/incbin/src/main.c @@ -0,0 +1,58 @@ +#include <gb/gb.h> +#include <stdint.h> + +#include <gb/incbin.h> + +INCBIN(logo_tiles_data, "res/gbdk2020.bin") // Variable name to use, Path to file +INCBIN_EXTERN(logo_tiles_data) // Extern declarations for binary data + +INCBIN(logo_map, "res/gbdk2020_map.bin") +INCBIN_EXTERN(logo_map) + +INCBIN(blank_tile_data, "res/blanktile.bin") +INCBIN_EXTERN(blank_tile_data) + + +#define TILE_BYTES 16 // 16 bytes per background tile + + +// Since incbin just includes a binary file (the logo tiles) +// a map needs to be created for them. For this example +// the tiles are non-deduplciated, so a array of incrementing +// values can be used. There are 84 tiles. +#define LOGO_MAP_WIDTH 7u +#define LOGO_MAP_HEIGHT 12u +#define LOGO_MAP_X (20u - LOGO_MAP_WIDTH) / 2u // Center on X axis +#define LOGO_MAP_Y (18u - LOGO_MAP_HEIGHT) / 2u // Center on Y axis + +void init_gfx() { + // Load a single clear background tile at location 0x80 and clear/fill the map with it + set_bkg_data(0x80u, 1u, blank_tile_data); // The first 0x80u here is the tile ID + fill_bkg_rect(0u, 0u, 20u, 18u, 0x80u); // The last 0x80u here is the tile ID + + // Load logo background tiles and map + // They start at 0u + set_bkg_data(0u, SIZE(logo_tiles_data) / TILE_BYTES, logo_tiles_data); + set_bkg_tiles(LOGO_MAP_X, LOGO_MAP_Y, + LOGO_MAP_WIDTH, LOGO_MAP_HEIGHT, + logo_map); + + // Turn the background map on to make it visible + SHOW_BKG; +} + + + +void main(void) +{ + init_gfx(); + + // Loop forever + while(1) { + + // Game main loop processing goes here + + // Done processing, yield CPU and wait for start of next frame + wait_vbl_done(); + } +} diff --git a/gbdk-lib/examples/ap/irq/Makefile b/gbdk-lib/examples/ap/irq/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = irq.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/irq/irq.c b/gbdk-lib/examples/ap/irq/irq.c @@ -0,0 +1,62 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <gb/console.h> +#include <stdio.h> +#include <string.h> + +// counters are 16-bit so we need a mutual exclusion access +unsigned int vbl_cnt, tim_cnt; + +void vbl() +{ + // Upon IRQ, interrupts are automatically disabled + vbl_cnt++; +} + +void tim() +{ + // Upon IRQ, interrupts are automatically disabled + tim_cnt++; +} + +void print_counter() +{ + unsigned int cnt; + + // Ensure mutual exclusion + CRITICAL { + cnt = tim_cnt; + } + + printf(" TIM %u", cnt); + gotoxy(9, posy()); + + // Ensure mutual exclusion + CRITICAL { + cnt = vbl_cnt; + } + + printf("- VBL %u\n", cnt); +} + +void main() +{ + // Ensure mutual exclusion + CRITICAL { + vbl_cnt = tim_cnt = 0; + add_VBL(vbl); + add_TIM(tim); + } + + // Set TMA to divide clock by 0x100 + TMA_REG = 0x00U; + // Set clock to 4096 Hertz + TAC_REG = 0x04U; + // Handle VBL and TIM interrupts + set_interrupts(VBL_IFLAG | TIM_IFLAG); + + while(1) { + print_counter(); + delay(1000UL); + } +} diff --git a/gbdk-lib/examples/ap/large_map/Makefile b/gbdk-lib/examples/ap/large_map/Makefile @@ -0,0 +1,11 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +all: + $(CC) -o large_map.pocket large_map.c bigmap_map.c bigmap_tiles.c + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm diff --git a/gbdk-lib/examples/ap/large_map/Readme.md b/gbdk-lib/examples/ap/large_map/Readme.md @@ -0,0 +1,14 @@ + +Large Map +========= + +Shows how to scroll with maps larger than 32 x 32 tiles using set_bkg_submap(). + +It fills rows and columns at the edges of the visible viewport (of the hardware +Background Map) with the desired sub-region of the large map as it scrolls. + + +Overworld Map and Tiles are by ArMM1998: +https://opengameart.org/content/gameboy-tileset +License(s): CC0 + diff --git a/gbdk-lib/examples/ap/large_map/bigmap_map.c b/gbdk-lib/examples/ap/large_map/bigmap_map.c @@ -0,0 +1,1661 @@ +/* + + BIGMAP_MAP.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 247 x 66 + Tile set : bigmap_tiles.gbr + Plane count : 1 plane (8 bits) + Plane order : Planes are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define bigmap_mapWidth 247 +#define bigmap_mapHeight 66 +#define bigmap_mapBank 0 + +#define bigmap_map bigmap_mapPLN0 +const unsigned char bigmap_mapPLN0[] = +{ + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x00,0x01,0x00,0x01,0x04,0x05,0x04,0x05,0x04,0x05, + 0x04,0x05,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06,0x07,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x09,0x06,0x04,0x05,0x06,0x06,0x06,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x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x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x1B,0x1C,0x1F,0x1F, + 0x1F,0x20,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x00,0x01,0x00,0x01,0x00,0x01, + 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x06,0x06, + 0x06,0x06,0x04,0x05,0x04,0x05,0x00,0x01,0x00,0x01, + 0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,0x06,0x06, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x0A,0x0B,0x06,0x06, + 0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x04,0x05, + 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x30,0x3F,0x40,0x41,0x42,0x9B,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0C, + 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x02,0x03,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x0F,0x06,0x06,0x0C,0x0D,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x39,0x4C,0x4D,0x08,0x09,0x9B,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01, + 0x02,0x03,0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01, + 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x19,0x1A,0x06,0x06,0x06,0x06,0x19,0x19, + 0x00,0x01,0x02,0x03,0x00,0x01,0x12,0x13,0x00,0x01, + 0x02,0x03,0x06,0x06,0x02,0x03,0x00,0x01,0x1B,0x1C, + 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x1F,0x1F,0x1F,0x1F, + 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x20,0x0B,0x0A,0x0B, + 0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x14,0x15, + 0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x23,0x21,0x22,0x24,0x25, + 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x02,0x03,0x06,0x06,0x00,0x01,0x02,0x03, + 0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x39,0x14,0x15, + 0x24,0x25,0x9B,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x26, + 0x27,0x06,0x06,0x06,0x06,0x28,0x26,0x0A,0x0B,0x12, + 0x13,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x2A,0x03,0x02,0x03,0x06,0x0C,0x0D, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x0F,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x3C,0xA5,0xA5,0xA5,0xA5,0xA6, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x00,0x01,0x10,0x11,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x1A,0x06,0x06,0x06,0x02,0x03, + 0x02,0x03,0x02,0x03,0x00,0x01,0x06,0x2B,0x06,0x06, + 0x06,0x06,0x2B,0x06,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06, + 0x02,0x03,0x2C,0x06,0x06,0x06,0x12,0x13,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x2D,0x04,0x05,0x04,0x04,0x04,0x04,0x05,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x14,0x15,0x21,0x22, + 0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x24,0x25, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06, + 0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x06,0xD8,0xDB,0xDB,0xDB,0xDB,0xDC,0x06,0x02,0x03, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x0A, + 0x0B,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x27,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x06,0x06,0x2E,0x2F,0x2E,0x2F,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x30, + 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x32,0x0C,0x0D, + 0x0C,0x0C,0x0C,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06, + 0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04, + 0x05,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0xD8,0xE1, + 0xE1,0xE1,0xE1,0xE2,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x00,0x01,0x06,0x06, + 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x33,0x19, + 0x34,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01, + 0x06,0x35,0x36,0x36,0x36,0x36,0x2E,0x06,0x02,0x03, + 0x00,0x01,0x00,0x01,0x00,0x01,0x1B,0x1C,0x37,0x38, + 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x39,0x06,0x06,0x06, + 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x31,0x06,0x06,0x2D,0x12,0x13,0x04,0x05,0x04, + 0x05,0x06,0x06,0x06,0x06,0x05,0x05,0x0D,0x0C,0x05, + 0x04,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,0x04,0x05, + 0x0C,0x0D,0x04,0x05,0x06,0x06,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x06,0x31, + 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x44,0x45,0x06,0xD8,0x80,0x80,0x80,0x80, + 0xB6,0x06,0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x0A,0x0B,0x06,0x06,0x17,0x18,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x3A,0x26,0x3B,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x2F,0x36, + 0x36,0x36,0x36,0x2E,0x2F,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x3C,0x3D,0x3E,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31, + 0x06,0x32,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x06,0x06, + 0x06,0x06,0x0D,0x0D,0x05,0x04,0x0D,0x0C,0x06,0x06, + 0x06,0x04,0x05,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,0x06,0x06,0x0C, + 0x0D,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13, + 0x06,0x31,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x50, + 0x51,0x06,0xDD,0xE1,0xE1,0xE1,0xE1,0xE2,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x00,0x01,0x06,0x06,0x06,0x06,0x02,0x03,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06, + 0x06,0x06,0x3F,0x40,0x41,0x42,0x12,0x13,0x12,0x13, + 0x00,0x01,0x02,0x03,0x06,0x35,0x36,0x36,0x36,0x36, + 0x36,0x36,0x1B,0x1C,0x1D,0x1E,0x1D,0x1E,0x1D,0x1E, + 0x43,0x06,0x06,0x06,0x06,0x06,0x44,0x45,0x06,0x06, + 0x46,0x47,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2D,0x02, + 0x03,0x04,0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0D,0x0C,0x06,0x06,0x06,0x06,0x06,0x0C,0x0D, + 0x06,0x06,0x06,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x04,0x05, + 0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x02,0x03,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x06,0x44,0x45,0x06,0x06,0x46, + 0x80,0x80,0x80,0x80,0xB6,0x06,0x06,0x06,0x44,0x45, + 0x02,0x03,0x00,0x01,0x02,0x03,0x00,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x4C, + 0x4D,0x4E,0x4F,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x2F,0x36,0x36,0x36,0x36,0x36,0x36,0x29, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x50,0x51,0x06,0x06,0x52,0x53,0x30, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x0C,0x0D, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x3F,0x40,0x54,0x55,0x54,0x55,0x54,0x55, + 0x55,0x56,0x57,0x58,0x59,0x55,0x55,0x54,0x55,0x54, + 0x55,0x41,0x42,0x0C,0x0D,0x0C,0x0D,0x04,0x05,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x02,0x03, + 0x02,0x03,0x02,0x03,0x12,0x13,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x50,0x51,0x06,0x06,0xDD,0xE1,0xE1,0xE1, + 0xE1,0xE2,0x06,0x06,0x31,0x50,0x51,0x06,0x06,0x0A, + 0x0B,0x06,0x06,0x0A,0x00,0x01,0x12,0x13,0x06,0x06, + 0x06,0x06,0x06,0x5A,0x19,0x19,0x19,0x19,0x1A,0x06, + 0x06,0x06,0x3F,0x40,0x54,0x55,0x5B,0x08,0x08,0x5C, + 0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x35, + 0x36,0x36,0x36,0x36,0x36,0x36,0x2C,0x06,0x3F,0x40, + 0x54,0x55,0x41,0x42,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x2C,0x06,0x06,0x06, + 0x06,0x06,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x06,0x06, + 0x06,0x06,0x2D,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x4C, + 0x4D,0x63,0x64,0x63,0x64,0x63,0x64,0x64,0x65,0x66, + 0x67,0x68,0x64,0x64,0x63,0x64,0x63,0x64,0x4E,0x09, + 0x06,0x06,0x04,0x05,0x0C,0x0D,0x06,0x06,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x31, + 0x06,0x06,0x06,0x0A,0x0B,0x06,0xA1,0xA2,0x06,0x06, + 0x06,0x0A,0x0B,0x06,0x06,0x06,0x02,0x03,0x02,0x03, + 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01, + 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x12,0x13, + 0x06,0x06,0x06,0x46,0x81,0x82,0x83,0x80,0xB6,0x06, + 0x06,0x06,0x06,0x06,0x44,0x45,0x00,0x01,0x06,0x06, + 0x02,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x69,0x26,0x26,0x26,0x26,0x27,0x06,0x06,0x06,0x4C, + 0x4D,0x63,0x64,0x6A,0x08,0x08,0x09,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0x36, + 0x36,0x36,0x36,0x30,0x06,0x4C,0x4D,0x63,0x64,0x4E, + 0x4F,0x06,0x06,0x06,0x6B,0x6C,0x6D,0x6C,0x6D,0x6C, + 0x6D,0x6C,0x6D,0x30,0x06,0x06,0x31,0x06,0x06,0x6E, + 0x6F,0x70,0x71,0x72,0x73,0x06,0x06,0x06,0x06,0x32, + 0x05,0x04,0x06,0x06,0x06,0x05,0x04,0x0D,0x0C,0x05, + 0x06,0x06,0x06,0x3F,0x40,0x55,0x5B,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x41,0x42,0x0C, + 0x0D,0x06,0x04,0x05,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x02,0x03,0x06,0xAF,0xB0,0x06,0x06,0x06,0x02,0x03, + 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x52,0x90,0x91,0x92,0x8F,0xC0,0x06,0x06,0x06,0x06, + 0x06,0x50,0x51,0x0A,0x0B,0x06,0x06,0x06,0x00,0x01, + 0x00,0x01,0x06,0x31,0x06,0x06,0x06,0x7A,0x06,0x06, + 0x5D,0x5E,0x5F,0x60,0x7B,0x7C,0x74,0x08,0x08,0x08, + 0x7D,0x7E,0x08,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62, + 0x06,0x06,0x06,0x2F,0x7F,0x36,0x36,0x36,0x1B,0x1C, + 0x43,0x06,0x0E,0x08,0x08,0x08,0x08,0x0F,0x06,0x06, + 0x06,0x2D,0x80,0x81,0x82,0x83,0x80,0x81,0x80,0x81, + 0x2C,0x06,0x06,0x06,0x31,0x06,0x84,0x85,0x86,0x87, + 0x08,0x88,0x06,0x06,0x06,0x06,0x2D,0x0D,0x0C,0x04, + 0x05,0x06,0x0D,0x0C,0x05,0x04,0x0D,0x06,0x06,0x06, + 0x4C,0x4D,0x64,0x6A,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x75,0x76,0x77,0x78,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x89,0x4E,0x4F,0x06,0x06,0x06,0x0C, + 0x0D,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13, + 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06, + 0x06,0x06,0x02,0x03,0x02,0x03,0x06,0x31,0x06,0x06, + 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06, + 0x02,0x03,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x02,0x03,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x31,0x06,0x06,0x8A,0x06,0x06,0x6E,0x6F,0x70, + 0x8B,0x72,0x8C,0x07,0x08,0x08,0x08,0x8D,0x8E,0x08, + 0x09,0x6E,0x6F,0x70,0x71,0x72,0x73,0x06,0x06,0x06, + 0x06,0x06,0x06,0x36,0x36,0x29,0x06,0x06,0x06,0x14, + 0x15,0x08,0x08,0x24,0x25,0x06,0x06,0x06,0x32,0x8F, + 0x90,0x91,0x92,0x8F,0x90,0x8F,0x90,0x30,0x06,0x06, + 0x06,0x06,0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x06, + 0x31,0x06,0x06,0x32,0x05,0x04,0x0C,0x0D,0x04,0x05, + 0x04,0x0D,0x0C,0x06,0x06,0x06,0x06,0x74,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x75, + 0x76,0x77,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x79,0x41,0x42,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06, + 0x06,0x33,0x34,0x06,0x99,0x08,0x86,0x87,0x9A,0x88, + 0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x84,0x85, + 0x86,0x87,0x08,0x88,0x06,0x06,0x31,0x06,0x06,0x06, + 0x7F,0x36,0x39,0x06,0x06,0x06,0x06,0x9B,0x9C,0x08, + 0x39,0x06,0x06,0x06,0x06,0x9B,0x9D,0x06,0x06,0x06, + 0x06,0x9E,0x9F,0xA0,0x2C,0x06,0x06,0x06,0x06,0x06, + 0xA1,0xA2,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06, + 0x2D,0x0D,0x0C,0x06,0x06,0x0C,0x0D,0x0C,0x05,0x04, + 0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x75,0xA3,0xA4,0x78, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89, + 0x4E,0x4F,0x06,0x06,0x04,0x05,0x06,0x06,0x02,0x03, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x06,0x31,0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06, + 0x31,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06, + 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01, + 0x12,0x13,0x12,0x13,0x31,0x06,0x06,0x06,0x12,0x13, + 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x3A,0x3B, + 0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x14,0x15,0x21, + 0x22,0x21,0x22,0x24,0x25,0x93,0x94,0x95,0x96,0x97, + 0x98,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x3C, + 0x3D,0x6C,0x6D,0xA5,0xA6,0xA7,0xA8,0x3C,0x3D,0xA9, + 0xAA,0xA5,0xA6,0xAB,0x06,0x06,0x06,0x06,0xAC,0xAD, + 0xAE,0x30,0x06,0x06,0x06,0x06,0x06,0xAF,0xB0,0x36, + 0x36,0xB1,0x06,0x31,0x06,0x06,0x06,0x32,0x04,0x05, + 0x06,0x06,0x06,0x04,0x05,0x0D,0x0C,0x04,0x06,0x06, + 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x75,0xB2,0xB3,0x78,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06, + 0x06,0x0C,0x0D,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x31, + 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x12,0x13,0x12, + 0x13,0x12,0x13,0x12,0x13,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x02,0x03, + 0x06,0x06,0xB4,0xB5,0x5F,0x60,0x61,0x62,0xA1,0xA2, + 0x36,0x36,0x2E,0x06,0x12,0x13,0x06,0x06,0x06,0x06, + 0x06,0x06,0xA1,0xA2,0x36,0x36,0x2E,0x06,0x06,0x31, + 0x06,0x5A,0x19,0x19,0x19,0x19,0x46,0x47,0x80,0x81, + 0x80,0xB6,0xB7,0xB8,0x46,0x47,0xB9,0xBA,0x80,0xB6, + 0x9D,0x06,0x06,0x06,0x06,0x9E,0x06,0x06,0x2C,0x06, + 0x06,0x06,0x12,0x13,0x06,0x35,0x36,0x36,0x2E,0x06, + 0x06,0x06,0x06,0x06,0x2D,0x0C,0x0D,0x06,0x06,0x06, + 0x0C,0x0D,0x05,0x04,0x0C,0x06,0x06,0x06,0x07,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0xBB, + 0xBC,0xA3,0xA4,0xBD,0x22,0x22,0x22,0x16,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x04,0x05,0x04, + 0x05,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x06,0x06,0x12,0x13,0x00,0x01, + 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x06,0x06,0x31,0x06,0x12,0x13,0x31,0x06, + 0x06,0x06,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B, + 0x0A,0x0B,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06, + 0x12,0x13,0x12,0x0A,0x0B,0x06,0x06,0x06,0x06,0xBE, + 0x6F,0x70,0x71,0x72,0x73,0xAF,0xB0,0x36,0x36,0xB1, + 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0xAF, + 0xB0,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x69,0x26, + 0x26,0x26,0x26,0x52,0x53,0x8F,0x90,0xBF,0xC0,0xC1, + 0xC2,0x52,0x53,0xC3,0xC4,0xBF,0xC0,0xAB,0x06,0x06, + 0x06,0x06,0xAC,0x06,0x06,0x30,0x06,0x06,0x06,0x0A, + 0x0B,0x06,0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06, + 0x06,0x32,0x04,0x06,0x06,0x06,0x06,0x04,0x05,0x0D, + 0x0C,0x04,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0xC5,0xC6,0xC7, + 0xC8,0x06,0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x5C,0x06,0x0C,0x0D,0x0C,0x0D,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x00,0x01,0x06,0x06,0x06,0x06,0x99,0x08,0x86,0x87, + 0x08,0x88,0x06,0x35,0x36,0x36,0x2E,0x06,0x02,0x03, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x35,0x36,0x36, + 0x2E,0x06,0x44,0x45,0x06,0x2B,0x3F,0x40,0x54,0x55, + 0x54,0x55,0x54,0x55,0x54,0x55,0xC9,0xCA,0x41,0x42, + 0x06,0x06,0x44,0x45,0x9D,0x06,0x06,0x06,0x06,0x9E, + 0x06,0x06,0x2C,0x06,0x06,0x06,0x02,0x03,0x06,0x35, + 0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,0x2D,0x06, + 0x06,0x06,0x06,0x06,0x0C,0x0D,0x05,0x04,0x04,0x06, + 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x09,0x06,0x31,0x06,0x31,0x06,0x31,0x06, + 0x06,0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09, + 0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x00,0x01, + 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x02,0x03,0x12,0x13,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06, + 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x0A,0x0B, + 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06, + 0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x06, + 0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0xB1,0x06,0x50, + 0x51,0x06,0x06,0x4C,0x4D,0x63,0x64,0x63,0x64,0x63, + 0x64,0x63,0x64,0xCB,0xCC,0x4E,0x4F,0x06,0x06,0x50, + 0x51,0xAB,0x06,0x31,0x06,0x06,0xAC,0x06,0x06,0x30, + 0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0xB1, + 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x06,0x06, + 0x04,0x05,0x04,0x0D,0x0C,0x04,0x06,0x06,0x06,0x07, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C, + 0x31,0x31,0x06,0x31,0x31,0x06,0x31,0x06,0x74,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x0C, + 0x0D,0x04,0x05,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0A,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02, + 0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0B,0x00,0x01,0x06,0x06,0x06,0x06, + 0x06,0x35,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, + 0x2E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x35,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06, + 0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0xCD,0xCE,0x06, + 0x06,0x06,0x06,0x9E,0x06,0x06,0x2C,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x2D,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C, + 0x05,0x04,0x0C,0x06,0x06,0x06,0x74,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x31, + 0x06,0x31,0x31,0x06,0x06,0x07,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x0C,0x0D, + 0x06,0x06,0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06, + 0x31,0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01, + 0x00,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x2F,0x36, + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x2E,0x2F,0x2E, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36, + 0x36,0x2E,0x2F,0x2E,0x06,0x06,0x06,0x74,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x09,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06, + 0xAC,0x06,0x06,0x30,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x32, + 0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x0D,0x06,0x06, + 0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x09,0x06,0x06,0x31,0x31,0x06,0x06, + 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x4F,0x06,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0B,0x0A,0x0A,0x0B,0x0B,0xCF,0xD0, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7F,0x36, + 0x7F,0x36,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x36, + 0x2E,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x9E,0x06,0x06, + 0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x31,0x06,0x06,0x06,0x2D,0x06,0x06,0x06, + 0x06,0x06,0x0C,0x0D,0x06,0x06,0x06,0x31,0x06,0x06, + 0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x79,0x41,0x42,0x06,0x06,0x31,0x06,0x3F,0x40,0x5B, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06, + 0x06,0x0C,0x0D,0x06,0x06,0x06,0x02,0x03,0x06,0x06, + 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06, + 0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13, + 0x12,0x13,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x12,0x13,0x31,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x5A,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x36, + 0x36,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06, + 0x2F,0x2E,0x2F,0x36,0x36,0x36,0x36,0xB1,0x06,0x06, + 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0xAC,0x06,0x06,0x30,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x05, + 0x04,0x05,0x04,0x06,0x06,0x31,0x06,0x07,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x4E,0x4F, + 0x06,0x06,0x06,0x06,0x4C,0x4D,0x6A,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x04,0x05,0x04, + 0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0B,0x7A,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,0x36, + 0x2E,0x06,0x06,0x06,0x06,0x06,0x36,0x36,0x36,0x36, + 0x36,0x36,0x36,0x7F,0xB1,0x06,0x06,0x06,0x07,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0xD1,0xD2,0x04,0x05,0x2C,0x06,0x06,0x06,0x44,0x45, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x2D,0x06,0x06,0x06,0x06,0x04,0x0D,0x0C,0x0D,0x0C, + 0x06,0x06,0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x54,0x55,0x54, + 0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x24, + 0x24,0x25,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x06,0x06, + 0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x12,0x13,0x06,0x06,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x02,0x03, + 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x06,0x06,0x31,0x06,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x10,0x11,0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01, + 0x00,0x01,0x12,0x13,0x00,0x01,0x02,0x03,0x02,0x03, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x8A, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x36,0x36,0x2E,0x2F,0x2E, + 0x2F,0x2E,0x2F,0x36,0x36,0x36,0x36,0x36,0x36,0xB1, + 0x06,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06, + 0x06,0x06,0xD3,0xD4,0xD5,0xD4,0xD5,0xD6,0xD7,0x0C, + 0x0D,0x30,0x06,0x06,0x06,0x50,0x51,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06, + 0x06,0x06,0x0C,0x05,0x04,0x06,0x06,0x06,0x06,0x06, + 0x06,0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x64,0x64,0x63,0x64,0x6A,0x08, + 0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06, + 0x04,0x05,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x7A,0x06,0xA1,0xA2, + 0xA1,0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x7F,0x7F,0x36, + 0x7F,0x36,0x7F,0x36,0xB1,0x06,0x06,0x06,0x3F,0x40, + 0x54,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x04,0x05,0x04,0x05,0x39,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x06, + 0x0D,0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C, + 0x0D,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x02,0x03,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06, + 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01, + 0x12,0x13,0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03, + 0x06,0x06,0x31,0x06,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x8A,0x06,0xAF,0xB0,0xAF,0xB0,0xAF, + 0xB0,0xAF,0xB0,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x4C,0x4D,0x63,0x64,0x6A, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0C,0x0D,0x0C,0x0D,0x3C,0x3D,0x6C,0x6D,0x6C, + 0x6D,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5, + 0xA5,0xA6,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x14,0x15,0x22,0x16,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x24,0x25, + 0x06,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0B,0x0A,0x0B,0x0A,0x0B, + 0x0A,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x33,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19, + 0x19,0x19,0x19,0x19,0x34,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x3F,0x40,0x54,0x55,0x54,0x55, + 0x54,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79, + 0x41,0x42,0x06,0x06,0x04,0x05,0x04,0x05,0x3F,0x40, + 0x41,0x42,0xD8,0xD9,0xDA,0xD9,0xDA,0xD9,0xDB,0xDB, + 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDC,0x31, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x31,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x7D, + 0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06, + 0x0C,0x0D,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13, + 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x10,0x11,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x5A, + 0x19,0x19,0x19,0x19,0x19,0x19,0x34,0x19,0x19,0x19, + 0x19,0x5A,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x3A,0x26,0x26, + 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26, + 0x26,0x3B,0x06,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06, + 0x06,0x4C,0x4D,0x63,0x64,0x63,0x64,0x63,0x64,0x6A, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x4E,0x4F,0x06, + 0x06,0x0C,0x0D,0x0C,0x0D,0x4C,0x4D,0x4E,0x4F,0xDD, + 0xDE,0xDF,0xE0,0xDF,0xE0,0xE1,0xE1,0xE1,0xE1,0xE1, + 0xE1,0xE1,0xE1,0xE1,0xE1,0xE2,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x31,0x06,0x06,0x31,0x06,0x06,0x31, + 0x06,0x06,0x0E,0x08,0x08,0x08,0x8D,0x8E,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x23,0xBB,0xE3,0xBB,0xE3, + 0x24,0x25,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x69,0x26,0x26,0x26, + 0x26,0x3A,0x26,0x3B,0x26,0x26,0x26,0x26,0x69,0x06, + 0x31,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x54,0x55,0x54,0x55,0x54,0x55, + 0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55, + 0x54,0x56,0x57,0x58,0x59,0x55,0x54,0x55,0x5B,0x08, + 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08, + 0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x79,0x54,0x55,0x54,0x55, + 0x54,0x55,0x5B,0x08,0x08,0x5C,0x46,0x47,0x80,0x81, + 0x80,0x81,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x80,0x80,0xB6,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x74, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13, + 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06, + 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x06,0x5A,0x19,0x7A,0x06,0x06,0x06,0x06,0x3F,0x40, + 0x41,0x42,0x12,0x13,0x06,0x7A,0x34,0x19,0x19,0x5A, + 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x06,0x06,0x02,0x03,0x00,0x01,0x02,0x03, + 0x00,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63, + 0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x65,0x66, + 0x67,0x68,0xE4,0x63,0x64,0x6A,0x08,0x08,0x08,0x08, + 0x08,0x8D,0x8E,0x08,0x08,0x7D,0x7E,0x08,0x08,0x8D, + 0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x89,0x63,0x64,0x63,0x64,0x63,0x64,0x6A, + 0x08,0x08,0x09,0x52,0x53,0x8F,0x90,0x8F,0x90,0xBF, + 0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xC0, + 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x31,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09, + 0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x0C,0x0D,0x04, + 0x05,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x69,0x26, + 0x26,0x06,0x06,0x06,0x06,0x4C,0x4D,0x4E,0x4F,0x0A, + 0x0B,0x06,0x26,0x3B,0x26,0x26,0x7A,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,0x7D, + 0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79, + 0x54,0x55,0x41,0x42,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06, + 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06, + 0x06,0x06,0x0C,0x0D,0x04,0x05,0x0C,0x0D,0x04,0x05, + 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x5A, + 0x19,0x19,0x19,0x19,0x19,0x7A,0x06,0x06,0x3F,0x40, + 0x54,0x55,0x5B,0x08,0x08,0x5C,0x02,0x03,0x06,0x06, + 0x06,0x06,0x06,0x7A,0x06,0x06,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06, + 0x00,0x01,0x12,0x13,0x00,0x08,0x08,0x7D,0x7E,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x75,0xA3,0xA4,0x78,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x63,0x64,0x4E, + 0x4F,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x31,0x06,0x06,0x06,0x06, + 0x31,0x06,0x06,0x06,0x06,0x06,0x3F,0x40,0x54,0x55, + 0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0C,0x0D,0x06,0x06,0x0C,0x0D,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x3F,0x40,0x54,0x55,0x55,0x55,0x55,0x54,0x55,0x41, + 0x42,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x69,0x26,0x26,0x26, + 0x26,0x26,0x26,0x06,0x06,0x4C,0x4D,0x63,0x64,0x6A, + 0x08,0x08,0x09,0x06,0x06,0x06,0x12,0x13,0x06,0x06, + 0x8A,0x06,0x31,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x08,0x08,0x8D,0x8E,0x08,0x08,0xE5,0xE6, + 0xE7,0xE8,0xE9,0xEA,0x08,0x08,0x08,0x08,0x08,0x75, + 0xB2,0xB3,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x4C,0x4D,0x63,0x64,0x6A,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x09,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x4C,0x4D,0x63, + 0x64,0x64,0x64,0x64,0x63,0x64,0x4E,0x4F,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x31, + 0x06,0x31,0x06,0x7A,0x06,0x06,0x5D,0x5E,0x5F,0x60, + 0x7B,0x7C,0x74,0x08,0x08,0x08,0x7D,0x7E,0x08,0x5C, + 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x7A,0x06,0x06, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x08, + 0x08,0x08,0x08,0x08,0x08,0xBE,0x6F,0x70,0x71,0x72, + 0x73,0x21,0x22,0x21,0x22,0x21,0xBC,0xA3,0xA4,0xBD, + 0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x09,0x54,0x55,0x54,0x55,0x54, + 0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54, + 0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55, + 0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x41,0x56, + 0x57,0x58,0x59,0x55,0x54,0x55,0x54,0x55,0x54,0x55, + 0x54,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54, + 0x55,0x54,0x55,0x55,0x5B,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x5C,0x55,0x55,0x54,0x55,0x41, + 0x42,0x06,0x06,0x06,0x06,0x31,0x06,0x31,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x31,0x06,0x06, + 0x8A,0x06,0x06,0x6E,0x6F,0x70,0x8B,0x72,0x8C,0x07, + 0x08,0x08,0x08,0x8D,0x8E,0x08,0x09,0x06,0x06,0x06, + 0x02,0x03,0x06,0x06,0x8A,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x1B,0x1C,0x1D,0x1E, + 0x1F,0x20,0x99,0x08,0x86,0x87,0x9A,0x88,0x1A,0x06, + 0x06,0x06,0x06,0xC5,0xC6,0xC7,0xC8,0x06,0x0E,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x64,0x63,0x64,0x64,0x63,0x64,0x63,0x64, + 0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x63,0x64,0x63, + 0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x89,0x4E,0x65,0x66,0x67,0x68, + 0xE4,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x63,0x64, + 0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64, + 0x64,0x6A,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x64,0x64,0x64,0x63,0x64,0x4E,0x4F,0x06,0x44, + 0x45,0x31,0x06,0x31,0x06,0x06,0x02,0x03,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x33,0x06,0x06, + 0x99,0x08,0x86,0x87,0x9A,0x88,0x0E,0x08,0x08,0x08, + 0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x8A,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x29,0x06,0x06,0x06,0x06,0x2A,0x93, + 0x94,0x95,0x96,0x97,0x98,0x27,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x14,0x15,0xBB,0xE3,0xBB, + 0xE3,0xBB,0xE3,0xBB,0xE3,0xEB,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x5C,0x06,0x50,0x51,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x5A,0x19, + 0x19,0x06,0x06,0x06,0x33,0x06,0x06,0x93,0x94,0x95, + 0x96,0x97,0x98,0x0E,0x08,0x08,0x7D,0x7E,0x08,0x08, + 0x09,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7A,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x43,0x06,0x12,0x13,0x06,0x2D,0x06,0x06,0x06,0x06, + 0x06,0x06,0x2B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x75,0xA3,0xA4,0x78,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x09,0x31,0x06,0x06,0x06,0x06,0x31,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x06,0x06,0x06,0x69,0x26,0x7A,0x06,0x06, + 0x06,0x7A,0x06,0x06,0xA1,0xA2,0x36,0x36,0x2E,0x06, + 0x14,0x15,0x16,0x8D,0x8E,0x08,0x08,0x25,0xA1,0xA2, + 0x36,0x36,0x2E,0x06,0x06,0x8A,0x06,0x06,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x0A, + 0x0B,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0xEC,0x06,0x06,0x06,0x06,0xD3,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x14, + 0x15,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x75,0xB2,0xB3, + 0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06, + 0x06,0x06,0x44,0x45,0x1B,0x1C,0x37,0x38,0x1D,0x1E, + 0x1D,0x1E,0x1D,0x1F,0x20,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x5A, + 0x19,0x19,0x7A,0x06,0x26,0x06,0x06,0x06,0x26,0x06, + 0x06,0xAF,0xB0,0x36,0x36,0xB1,0x06,0x06,0x06,0x0E, + 0x08,0x08,0x08,0x09,0x06,0xAF,0xB0,0x36,0x36,0xB1, + 0x06,0x06,0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x12,0x13,0x00,0x01,0x06,0x2D, + 0x19,0x19,0x19,0x19,0x34,0x06,0x06,0x06,0x06,0x06, + 0x9E,0x06,0x06,0x06,0x06,0xED,0x02,0x03,0x00,0x01, + 0x00,0x01,0x02,0x03,0x02,0x03,0x06,0x06,0x74,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x7D, + 0x7E,0x08,0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08, + 0x23,0xBB,0xE3,0xBB,0xE3,0xBB,0xE3,0xBB,0xE3,0x15, + 0xBB,0xE3,0xBB,0xE3,0xE3,0x22,0x21,0xBB,0xE3,0xE3, + 0xBB,0x22,0x21,0xE3,0xBB,0x22,0x21,0xBB,0xE3,0xBB, + 0xE3,0xBB,0xE3,0x15,0xBB,0xE3,0xBB,0xE3,0x22,0x21, + 0x22,0x21,0x22,0x21,0xBC,0xA3,0xA4,0xBD,0x22,0xE3, + 0x15,0xBB,0xE3,0xBB,0xE3,0x15,0x21,0x22,0x21,0x22, + 0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22, + 0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x50, + 0x51,0x30,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x32,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x06,0x06,0x7A,0x26,0x26,0x26, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x35, + 0x36,0x36,0x2E,0x06,0x06,0x06,0x14,0xE3,0xE3,0x24, + 0x25,0x06,0x06,0x35,0x36,0x36,0x2E,0x06,0x06,0x8A, + 0x06,0x31,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0xA1,0xA2,0x00,0x01,0x00,0x01, + 0x00,0x0A,0x0B,0x0A,0x0B,0x06,0x32,0x26,0x26,0x26, + 0x26,0x3B,0x06,0x06,0x06,0x06,0x06,0xAC,0x06,0x06, + 0x06,0x06,0xEE,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E, + 0x08,0x08,0x7D,0x7E,0x08,0x08,0x8D,0x8E,0x08,0x08, + 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x5C,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0xC5,0xC6,0xC7,0xC8,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12, + 0x13,0x06,0x06,0x12,0x13,0x06,0x06,0x74,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x79,0x41,0x42,0x06,0x06,0x06,0x2C,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2D,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x7A,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x2F,0x2E,0x06,0x36,0x36,0x36, + 0x2E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x35,0x36,0x36,0x2E,0x06,0x06,0x7A,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0xAF,0xB0,0x0A,0x0B,0x0A,0x0B,0x0A,0x02,0x03, + 0x00,0x01,0x06,0x2D,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x9E,0x06,0x06,0x06,0x06,0xED, + 0x06,0x06,0x02,0x03,0x02,0x03,0x04,0x05,0x06,0x06, + 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D, + 0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x8D,0x8E,0x08,0x09,0x06,0x06,0x06,0x12,0x13, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06, + 0x0A,0x0B,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89, + 0x4E,0x4F,0x06,0x06,0x06,0x30,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x02,0x03, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x06, + 0x8A,0x06,0x06,0x06,0x06,0x44,0x45,0x06,0x06,0x35, + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x2E,0x06,0x06, + 0x06,0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x36,0x36, + 0x36,0x2E,0x06,0x8A,0x06,0x06,0x00,0x01,0x00,0x01, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x0A,0x0B,0x06, + 0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0xAC,0x06,0x06,0x06,0x06,0xEE,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0C,0x0D,0x06,0x06,0x06,0x06,0x07, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x21,0x22,0x22, + 0x24,0x25,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00, + 0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x06, + 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4F,0x06, + 0x06,0x06,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x8A,0x06,0x31, + 0x06,0x06,0x50,0x51,0x06,0x06,0x2F,0x2E,0x2E,0x06, + 0x06,0x2F,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,0x06, + 0x06,0x06,0x2F,0x36,0x36,0x36,0x36,0x36,0xB1,0x06, + 0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x06,0x06,0x02,0x03,0x06,0x2D,0x12,0x13, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x9D,0x06, + 0x06,0x06,0x06,0xCD,0x06,0x06,0x04,0x05,0x04,0x05, + 0x04,0x05,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x5C,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x00,0x01,0x06,0x06,0x12,0x13,0x06,0x06, + 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x31,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x06, + 0x06,0x06,0x06,0x04,0x06,0x06,0x06,0x06,0x06,0x06, + 0x31,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B, + 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x07,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x4F,0x06,0x06,0x06,0x30, + 0x06,0x06,0x6B,0x6C,0x6D,0x6C,0x6D,0x6C,0x6D,0xA6, + 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x06,0x06,0x33,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x36,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x2F,0x36, + 0x2F,0x36,0x36,0x36,0x2E,0x06,0x06,0x7A,0x06,0x06, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x06, + 0x06,0x06,0x06,0x06,0x32,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0xAB,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06, + 0x06,0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x09,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05, + 0x04,0x05,0x04,0x05,0x04,0x04,0x06,0x06,0x05,0x04, + 0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06, + 0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00, + 0x01,0x00,0x01,0x06,0x06,0x0E,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x4F,0x06,0x06,0x06,0x2C,0x06,0x06,0x2D, + 0x80,0x81,0x82,0x83,0x80,0x81,0xDC,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x7A,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x31, + 0x06,0x06,0x06,0x06,0x12,0x13,0x35,0x36,0x36,0x2E, + 0x06,0x12,0x13,0x06,0x06,0x06,0x2F,0x36,0x36,0x36, + 0x36,0xB1,0x06,0x06,0x8A,0x06,0x31,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x06,0x06, + 0x06,0x9B,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0xCD, + 0xEF,0xF0,0xCE,0x06,0x06,0x06,0x04,0x05,0x04,0x05, + 0x12,0x13,0x04,0x05,0x04,0x05,0x06,0x06,0x06,0x06, + 0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x00,0x01,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x31,0x06,0x06,0x06,0x06,0x0D,0x0C,0x0D,0x0C, + 0x0D,0x0C,0x06,0x06,0x06,0x0D,0x0C,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03,0x02,0x03, + 0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4F, + 0x06,0x06,0x06,0x30,0x06,0x06,0x32,0x8F,0x90,0x91, + 0x92,0x8F,0x8F,0x90,0x06,0x06,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x06,0x8A,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x2F,0x36,0x36,0xB1,0x06,0x0A,0x0B, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x7A,0x06,0x06,0x00,0x01,0x00,0x01,0x02,0x03, + 0x06,0x06,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x6C,0x6D,0x6C,0x6D,0xA5,0xA6,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0C, + 0x0D,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x14, + 0x15,0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x23,0x21,0x22,0x24,0x25,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x05,0x04,0x05,0x04,0x04,0x05,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x02, + 0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x4F,0x06,0x06,0x06, + 0x2C,0x06,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x7A,0x06,0xA1,0xA2,0xA1, + 0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x06,0x02,0x03, + 0x35,0x36,0x36,0x2E,0x06,0x02,0x03,0x06,0xA1,0xA2, + 0xA1,0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x8A,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x80,0x81,0x80,0x81,0x80,0xB6,0x00,0x01,0x00,0x01, + 0x12,0x13,0x12,0x13,0x12,0x13,0x04,0x05,0x04,0x05, + 0x04,0x05,0x12,0x13,0x02,0x03,0x04,0x05,0x04,0x05, + 0x04,0x05,0x06,0x06,0x44,0x45,0x12,0x13,0x06,0x06, + 0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x12,0x13, + 0x12,0x13,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0D, + 0x0C,0x0D,0x04,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06, + 0x06,0x12,0x13,0x0C,0x0D,0x04,0x04,0x05,0x04,0x05, + 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x14,0x15, + 0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x4F,0x06,0x06,0x06,0x30,0x06,0x06, + 0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x06,0x06,0x8A,0x06,0xAF,0xB0,0xAF,0xB0,0xAF,0xB0, + 0xAF,0xB0,0x06,0x06,0x06,0x06,0x19,0x06,0x06,0x06, + 0x06,0x06,0x19,0x06,0x06,0xAF,0xB0,0xAF,0xB0,0xAF, + 0xB0,0xAF,0xB0,0x06,0x06,0x7A,0x06,0x06,0x00,0x01, + 0x00,0x01,0x12,0x13,0x06,0x06,0x00,0x01,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x8F,0x90,0x8F, + 0x90,0xBF,0xC0,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x0A, + 0x0B,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06, + 0x06,0x50,0x51,0x0A,0x0B,0x06,0x06,0x14,0x15,0x21, + 0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21, + 0x22,0x21,0x22,0x24,0x25,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x0C, + 0x04,0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x0A,0x0B, + 0x12,0x13,0x0C,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x07, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x79,0x41,0x41,0x41,0x2C,0x06,0x06,0x2D,0x41,0x41, + 0x42,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x33, + 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19, + 0x19,0x19,0x19,0x28,0x06,0x06,0x06,0x06,0x06,0x28, + 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19, + 0x19,0x19,0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x12,0x13,0x06,0x06, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x1B,0x1C, + 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x1F,0x20,0x04,0x05, + 0x04,0x05,0x04,0x05,0x04,0x05,0x12,0x13,0x12,0x13, + 0x02,0x03,0x12,0x13,0x06,0x06,0x12,0x13,0x12,0x13, + 0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,0x06,0x06, + 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13, + 0x06,0x06,0x04,0x05,0x04,0x05,0x04,0x0C,0x06,0x06, + 0x06,0x06,0x0D,0x0C,0x0D,0x00,0x01,0x0A,0x0B,0x04, + 0x04,0x05,0x04,0x05,0x00,0x01,0x00,0x01,0x12,0x13, + 0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,0x12,0x13, + 0x06,0x06,0x31,0x06,0x06,0x06,0x0E,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x30,0x06,0x06,0x32,0x4E,0x4E,0x4F,0x06,0x06, + 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x06,0x06,0x26,0x26,0x26,0x26, + 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26, + 0x26,0x06,0x06,0x06,0x06,0x06,0x26,0x26,0x26,0x26, + 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26, + 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x2A,0x0C,0x0D,0x0C,0x0D,0x0C, + 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x12,0x13,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x04,0x0C, + 0x0D,0x0C,0x0D,0x0C,0x04,0x05,0x06,0x06,0x04,0x05, + 0x12,0x13,0x0A,0x0B,0x00,0x01,0x0C,0x0C,0x0D,0x0C, + 0x0D,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x2C,0x06, + 0x06,0x2D,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x12, + 0x13,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x12,0x13, + 0x02,0x03,0x44,0x45,0x10,0x11,0x00,0x01,0x00,0x01, + 0x02,0x03,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x2D,0x04,0x05,0x04,0x05,0x12,0x13,0x12,0x13, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13, + 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x0A,0x0B,0x02,0x03,0x10,0x11, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x06,0x0C,0x04,0x05,0x12,0x13, + 0x04,0x0C,0x0D,0x06,0x06,0x0C,0x0D,0x0A,0x0B,0x10, + 0x11,0x0A,0x0B,0x04,0x04,0x05,0x04,0x05,0x10,0x11, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13, + 0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06, + 0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x30,0x06,0x06,0x32,0x08, + 0x08,0x09,0x06,0x06,0x06,0x06,0x0A,0x0B,0x02,0x03, + 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x12,0x13, + 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06, + 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03, + 0x00,0x01,0x00,0x01,0x00,0x0A,0x0B,0x06,0x06,0x50, + 0x51,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x30, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x0C, + 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x00,0x01,0x12,0x13,0x17,0x18,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x06,0x06,0x0C,0x0D,0x0A,0x0B,0x0C,0x04,0x05, + 0x04,0x04,0x05,0x04,0x02,0x03,0x17,0x18,0x10,0x11, + 0x0C,0x0C,0x0D,0x0C,0x0D,0x17,0x18,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x74,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x23,0x24,0x2C,0x06,0x06,0x32,0x24,0x24,0x25,0x06, + 0x06,0x06,0x06,0x02,0x03,0x06,0x06,0x06,0x44,0x45, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x12, + 0x13,0x12,0x13,0x12,0x13,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x02,0x03,0x06,0x06,0x06,0x06,0x31,0x06, + 0x02,0x03,0x02,0x03,0x12,0x13,0x39,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x9B,0x04,0x05,0x04,0x05, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x10,0x11, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x0A,0x0B, + 0x0A,0x0B,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x06,0x04, + 0x04,0x05,0x00,0x01,0x04,0x0C,0x0D,0x0C,0x0C,0x0D, + 0x0C,0x0D,0x0D,0x06,0x06,0x17,0x18,0x04,0x04,0x05, + 0x04,0x05,0x04,0x05,0x02,0x03,0x02,0x03,0x02,0x03, + 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x00,0x01, + 0x12,0x13,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x30, + 0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x31,0x06,0x50,0x51,0x06,0x02,0x03, + 0x02,0x03,0x02,0x03,0x02,0x03,0x0A,0x0B,0x0A,0x0B, + 0x0A,0x0B,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x00,0x01,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x3C,0x3D,0x3E,0x06,0x06,0x06,0x06, + 0x6B,0xA5,0xA6,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,0x0B,0x02, + 0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x00,0x01,0x00,0x01,0x12, + 0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x0C,0x0C,0x0D,0x0A, + 0x0B,0x0C,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05, + 0x04,0x05,0x04,0x05,0x04,0x0C,0x0D,0x0C,0x0D,0x0C, + 0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00, + 0x01,0x00,0x01,0x00,0x01,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x09,0x06,0x2C,0x06,0x06,0x06, + 0x1D,0x1E,0x1D,0x1F,0x20,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x12,0x13, + 0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x06,0x02,0x03, + 0x46,0x47,0x39,0x06,0x06,0x06,0x06,0x9B,0x80,0xB6, + 0x04,0x05,0x04,0x05,0x10,0x11,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x10,0x11,0x12,0x13,0x02,0x03,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x12,0x13,0x06,0x06,0x02,0x03, + 0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03, + 0x02,0x03,0x06,0x04,0x04,0x05,0x10,0x11,0x04,0x0C, + 0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06, + 0x0D,0x04,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05, + 0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B, + 0x0A,0x0B,0x00,0x01,0x00,0x01,0x06,0x06,0x74,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x09,0x06,0x30,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01, + 0x00,0x01,0x00,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x52,0x53,0x3C, + 0x3D,0x6C,0x6D,0xA5,0xA6,0xBF,0xC0,0x0C,0x0D,0x0C, + 0x0D,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A, + 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x02, + 0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06, + 0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12, + 0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x0C,0x0C,0x0D,0x17,0x18,0x0C,0x04,0x05,0x05,0x04, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0C, + 0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06, + 0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x07,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06, + 0x39,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06, + 0x06,0x06,0x06,0x12,0x13,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x31,0x06,0x02,0x03,0x06,0x06,0x02,0x03,0x06,0x06, + 0x12,0x13,0x06,0x06,0x06,0x06,0x46,0x47,0x80,0x81, + 0x80,0xB6,0x44,0x45,0x04,0x05,0x04,0x05,0x04,0x05, + 0x02,0x03,0x02,0x03,0x02,0x03,0x0A,0x0B,0x0A,0x0B, + 0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x02,0x03,0x06,0x06, + 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B, + 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05, + 0x04,0x05,0x04,0x0C,0x0D,0x0D,0x0C,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01, + 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x39,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x9B,0x06,0x06,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13, + 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,0x12,0x13, + 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x06,0x31,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x52,0x53,0x8F,0x90,0xBF,0xC0,0x50, + 0x51,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06, + 0x06,0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00, + 0x01,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x12, + 0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x10,0x11,0x00,0x01,0x00, + 0x01,0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x31, + 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x07, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x09,0x06,0x3C,0x3D,0x6D,0x6C,0x6D,0x6D, + 0x6C,0x6D,0xA6,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x31,0x06,0x06,0x02,0x03,0x06,0x06,0x31,0x06, + 0x12,0x13,0x12,0x13,0x12,0x13,0x04,0x05,0x04,0x05, + 0x04,0x05,0x04,0x05,0x04,0x05,0x06,0x06,0x04,0x05, + 0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x0A,0x0B,0x12,0x13, + 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06, + 0x06,0x06,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B, + 0x0A,0x0B,0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31, + 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13, + 0x00,0x01,0x02,0x03,0x06,0x06,0x0E,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09, + 0x06,0x46,0x47,0x81,0x80,0x81,0x81,0x80,0x81,0xDC, + 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x0C, + 0x0D,0x0C,0x0D,0x06,0x06,0x0C,0x0D,0x06,0x06,0x02, + 0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x12,0x13,0x06,0x06,0x06,0x06,0x12, + 0x13,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x12, + 0x13,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06, + 0x06,0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x52,0x53, + 0x8F,0x8F,0x8F,0x8F,0x8F,0x8F,0x90,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06, + 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01, + 0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x06, + 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01, + 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03, + 0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06, + 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03, + 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x05,0x04,0x05, + 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x05,0x04,0x05,0x00,0x01,0x00,0x01, + 0x06,0x06,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13, + 0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,0x06, + 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03, + 0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0C, + 0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x12, + 0x13,0x06,0x06,0x02,0x03,0x06,0x06,0x02,0x03,0x02, + 0x03,0x02,0x03,0x00,0x01,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05, + 0x04,0x05,0x0C,0x0C,0x0D,0x0C,0x0D,0x0C,0x0C,0x05, + 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05, + 0x05,0x04,0x05,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x74,0x08,0x08, + 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, + 0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, + 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, + 0x0B,0x0A +}; + +/* End of BIGMAP_MAP.C */ diff --git a/gbdk-lib/examples/ap/large_map/bigmap_map.h b/gbdk-lib/examples/ap/large_map/bigmap_map.h @@ -0,0 +1,32 @@ +/* + + BIGMAP_MAP.H + + Map Include File. + + Info: + Section : + Bank : 0 + Map size : 247 x 66 + Tile set : bigmap_tiles.gbr + Plane count : 1 plane (8 bits) + Plane order : Planes are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ +#ifndef __bigmap_map_h_INCLUDE +#define __bigmap_map_h_INCLUDE + +#define bigmap_mapWidth 247 +#define bigmap_mapHeight 66 +#define bigmap_mapBank 0 + +#define bigmap_map bigmap_mapPLN0 +extern const unsigned char bigmap_mapPLN0[]; + +#endif + +/* End of BIGMAP_MAP.H */ diff --git a/gbdk-lib/examples/ap/large_map/bigmap_tiles.c b/gbdk-lib/examples/ap/large_map/bigmap_tiles.c @@ -0,0 +1,512 @@ +/* + + BIGMAP_TILES.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 240 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + +/* Start of tile array. */ +const unsigned char bigmap_tiles[] = +{ + 0x5C,0x63,0x33,0x3C,0x2D,0x10,0x5A,0x20, + 0xDD,0x20,0xBF,0x40,0xBF,0x40,0x1B,0x64, + 0x02,0xFE,0xCC,0x3C,0x74,0x08,0xFA,0x04, + 0xFB,0x04,0xFB,0x06,0xD3,0x2E,0xC6,0x3E, + 0x5C,0x63,0x3B,0x37,0x3C,0x0F,0x6F,0x18, + 0xCD,0x3A,0xC9,0x3E,0x3C,0x03,0x0F,0x00, + 0x02,0xFE,0xCC,0xFC,0x7C,0xF0,0x76,0xF8, + 0x73,0xFC,0x73,0xFC,0x3C,0xC0,0xF0,0x00, + 0x00,0x22,0x14,0x41,0x22,0x49,0x1C,0x22, + 0x00,0x00,0x00,0x44,0x28,0x82,0x44,0x92, + 0x00,0x00,0x00,0x22,0x14,0x41,0x22,0x49, + 0x1C,0x22,0x00,0x00,0x00,0x44,0x28,0x82, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x17,0x10,0x17,0x30,0x67,0x10,0x77,0x08, + 0x3B,0x08,0x0B,0x38,0x7B,0x18,0xE7,0x30, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFC,0x0E,0xF4,0x06,0xF7,0x08,0xEB,0x0C, + 0xE0,0x0E,0xEC,0x10,0xE6,0x18,0xE0,0x0C, + 0x63,0x9C,0x7D,0x82,0x7E,0x81,0xBB,0xC4, + 0xCF,0xFC,0x87,0xFC,0x82,0xFF,0x48,0x77, + 0xDA,0x3E,0x99,0x67,0x39,0xC7,0xA3,0x7F, + 0xBD,0x7F,0x21,0xFF,0xC1,0xFF,0x02,0xFE, + 0x38,0x44,0x00,0x00,0x00,0x22,0x14,0x41, + 0x22,0x49,0x1C,0x22,0x00,0x00,0x00,0x00, + 0x44,0x92,0x38,0x44,0x00,0x00,0x00,0x22, + 0x14,0x41,0x22,0x49,0x1C,0x22,0x00,0x00, + 0x0F,0x60,0x6F,0x10,0xEF,0x10,0xCF,0x20, + 0x1F,0x60,0x0F,0x30,0x0F,0x10,0x07,0x10, + 0xEC,0x10,0xD8,0x24,0xF8,0x18,0xAC,0x4C, + 0x93,0x64,0xD7,0x28,0xEE,0x08,0xEC,0x0E, + 0x5C,0x63,0x3B,0x37,0x3C,0x0F,0x6F,0x18, + 0xCD,0x3A,0xC9,0x3E,0xC4,0x3F,0x60,0x1F, + 0x02,0xFE,0xCC,0xFC,0x7C,0xF0,0x76,0xF8, + 0x73,0xFC,0x73,0xFC,0x63,0xFC,0xC6,0xF8, + 0x00,0x03,0x03,0x0C,0x0D,0x10,0x1A,0x20, + 0x1D,0x20,0x3F,0x40,0x3F,0x40,0x1B,0x64, + 0x00,0xC0,0xC0,0x30,0x70,0x08,0xF8,0x04, + 0xF8,0x04,0xFA,0x06,0xD2,0x2E,0xC6,0x3E, + 0x07,0x30,0x77,0x10,0xD7,0x30,0x23,0x7C, + 0x31,0x4E,0x74,0x0B,0x66,0x19,0x02,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xC1,0x3E, + 0x8C,0x73,0x2E,0xD1,0x27,0x00,0x0F,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x7F,0x80, + 0x9F,0x60,0x8F,0x30,0x2F,0x10,0x77,0x10, + 0x3C,0x03,0x0F,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3C,0xC0,0xF0,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00, + 0xBA,0x00,0xC6,0x82,0xDB,0xA7,0xDB,0xA6, + 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00, + 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xFA,0xAE, + 0xFF,0x06,0xFD,0x1B,0xE6,0x31,0xF2,0x20, + 0xF8,0x20,0xE0,0x30,0xF0,0x40,0xE0,0x90, + 0xFF,0xFB,0x35,0xCE,0xBB,0x40,0x9A,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xBE,0x4D,0xF3,0xAE,0x50,0xA6,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xE0,0x5F,0xBF,0xCC,0x33,0x9C,0x00, + 0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xEE,0xD5,0x3B,0xEC,0x03,0x69,0x00, + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0xF8,0xCF,0x36,0xC9,0x03, + 0x83,0x01,0x07,0x01,0x03,0x06,0x07,0x01, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x41,0xBE, + 0x0C,0xF3,0xAE,0x50,0xA6,0x00,0x00,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x1F,0xE0, + 0x40,0xBF,0xCC,0x33,0x9C,0x00,0x18,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFE,0x01, + 0xF9,0x06,0xF1,0x0C,0xF4,0x08,0xE6,0x08, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x9F,0x60, + 0x80,0x7F,0x0C,0xF3,0x7C,0x80,0xF8,0x00, + 0xF4,0x06,0xF8,0x02,0xF8,0x04,0xE3,0x1C, + 0xD1,0x2C,0x18,0xE0,0x08,0x60,0x40,0x00, + 0xBB,0xC7,0xA2,0xDE,0xA3,0xDF,0xE7,0x5C, + 0xF7,0xCF,0x54,0x6C,0x44,0x7C,0x00,0x38, + 0xBA,0xEE,0xAA,0xFE,0x82,0xC6,0x38,0x82, + 0xC6,0x82,0xDA,0xA6,0xDA,0xA6,0x92,0xEE, + 0xBB,0xEF,0xAA,0xFE,0x29,0x7D,0x01,0x44, + 0x39,0x83,0xC6,0x82,0xDA,0xA6,0xDA,0xA6, + 0xC0,0xE0,0xE0,0x30,0xFC,0x10,0xFC,0x20, + 0xF8,0x20,0xE0,0x38,0xF0,0x18,0xFC,0x20, + 0x0F,0x01,0x0F,0x02,0x03,0x06,0x0D,0x03, + 0x07,0x01,0x03,0x01,0x01,0x03,0x07,0x01, + 0xA2,0xDE,0xA2,0xDE,0x64,0x5C,0x74,0x4C, + 0x54,0x6C,0x44,0x7C,0x00,0x38,0x00,0x00, + 0xE0,0x30,0xF0,0x40,0xE0,0x90,0xC0,0xE0, + 0xE0,0x30,0xFC,0x10,0xF4,0x38,0xF8,0x20, + 0x0F,0x02,0x07,0x0C,0x0F,0x02,0x1F,0x02, + 0x1F,0x04,0x07,0x0C,0x1B,0x06,0x07,0x02, + 0x00,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00, + 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00, + 0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00, + 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00, + 0xE0,0x38,0xF0,0x18,0xFC,0x20,0xEC,0x30, + 0xE0,0x38,0xF0,0x40,0xD8,0x60,0xE0,0x30, + 0x00,0x00,0x00,0x00,0x20,0x00,0x32,0x00, + 0x16,0x00,0x04,0x00,0x00,0x00,0x00,0x00, + 0x03,0x02,0x03,0x06,0x0F,0x02,0x0F,0x01, + 0x07,0x01,0x01,0x07,0x0D,0x03,0x1B,0x06, + 0xAA,0xFE,0xAA,0xFE,0x28,0x7C,0x00,0x44, + 0x38,0x82,0xC6,0x82,0xDB,0xA7,0xDB,0xA6, + 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00, + 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xDA,0xA6, + 0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0xF7,0x00,0xF7,0x00,0xF7,0x00, + 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00, + 0xCF,0x80,0xF0,0x80,0xE0,0x80,0x60,0xC0, + 0xFE,0x40,0xA0,0xC0,0x40,0x80,0x80,0x00, + 0x79,0x01,0x07,0x01,0x01,0x01,0x03,0x02, + 0xCB,0x02,0x01,0x03,0x00,0x01,0x01,0x00, + 0xF0,0x40,0xC0,0x70,0xE0,0x30,0xF8,0x40, + 0xD8,0x60,0xC0,0x70,0xE0,0x80,0xB0,0xC0, + 0xBB,0xC7,0xA2,0xDE,0xA3,0xDF,0x67,0x5C, + 0x77,0x4F,0x54,0x6C,0x44,0x7C,0x00,0x38, + 0xBA,0xC6,0xA2,0xDE,0xA2,0xDE,0xE4,0x5C, + 0xF4,0xCC,0x54,0x6C,0x44,0x7C,0x00,0x38, + 0xC0,0x60,0xF0,0x40,0xE4,0x40,0xCE,0x60, + 0xFF,0x73,0xFF,0x4E,0xFB,0x46,0xF3,0x4E, + 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x80, + 0x32,0xC4,0xAB,0xDC,0xF5,0x7F,0xF3,0x0F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x30,0x00,0x70,0x80,0xE0,0x90,0x40,0xE0, + 0x00,0x00,0x0C,0x00,0x0E,0x01,0x06,0x09, + 0x01,0x1F,0x32,0x0E,0x1D,0x04,0x0E,0x1D, + 0x30,0x00,0x70,0x00,0x62,0x90,0x97,0xF8, + 0x9D,0x9A,0x6B,0x0F,0x10,0xE0,0x07,0xF8, + 0x00,0x00,0x00,0x00,0x06,0x80,0x07,0x88, + 0xCB,0x8C,0xED,0x9F,0x30,0x58,0xC4,0x73, + 0x0C,0x00,0x1C,0x00,0x58,0xE0,0x60,0xF8, + 0x80,0x8E,0x31,0x84,0x1F,0x68,0x0E,0xFC, + 0x40,0xE0,0xE0,0x90,0x70,0x80,0x30,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00, + 0x04,0x00,0x0B,0x00,0x1C,0x18,0x1D,0x12, + 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00, + 0x20,0x00,0xD0,0x00,0x30,0x10,0xD0,0x30, + 0xEB,0x5C,0xF1,0x3E,0xE3,0x3C,0xF7,0x28, + 0xFF,0x20,0xFB,0x44,0xFF,0x44,0xFF,0x44, + 0xF0,0x0F,0xE0,0x1F,0xE1,0x1E,0x47,0xBC, + 0x07,0xFC,0x8B,0x7C,0x99,0x76,0x9B,0x66, + 0x00,0x0F,0x00,0x30,0x00,0x40,0x03,0x40, + 0x3E,0x21,0x3B,0x3C,0x1D,0x13,0x1F,0x14, + 0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80, + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x00,0x00,0x00,0x01,0x00,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x00,0xF8,0x00,0x0C,0x00,0x02,0xC0,0x02, + 0x78,0x84,0xDC,0x3C,0xB8,0xC8,0xF8,0x28, + 0x48,0x3B,0x14,0x33,0x18,0x37,0x79,0x16, + 0x75,0x0A,0x39,0x0A,0x0B,0x38,0x73,0x18, + 0x50,0xAF,0xF9,0x06,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x08,0x87,0x21,0xDE,0x0B,0xF4,0x9F,0x60, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x04,0xF6,0x86,0x7E,0xD6,0x28,0xEF,0x08, + 0xEB,0x0C,0xEC,0x0E,0xEC,0x10,0xE6,0x18, + 0x0D,0x0A,0x19,0x0E,0x1C,0x07,0x0C,0x03, + 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0xF0,0x18,0xF0,0x38,0xE0,0xF0,0xC0, + 0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0x44,0xF3,0x4C,0xF1,0x4E,0xB2,0x4F, + 0xB2,0x4F,0xCF,0x3C,0x7F,0x00,0x3E,0x00, + 0x93,0x6E,0x31,0xCE,0x31,0xCE,0x33,0xCE, + 0xD3,0xEF,0xCF,0x3C,0xFF,0x00,0x7C,0x00, + 0x00,0x00,0x80,0x00,0xC2,0x10,0x96,0x78, + 0x0D,0x9B,0x6A,0x0E,0x91,0x60,0x04,0xFB, + 0x00,0x00,0x00,0x00,0x06,0x00,0x47,0x88, + 0xEB,0x9C,0xFC,0xDF,0x38,0x78,0x84,0x03, + 0x0F,0x0C,0x0D,0x0C,0x05,0x04,0x45,0x8C, + 0xED,0x9C,0xFD,0xDC,0x3D,0x7C,0x85,0x04, + 0xE0,0x9F,0xFF,0x80,0xFF,0x80,0xFF,0x80, + 0xC0,0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80, + 0x07,0xF9,0xFF,0x01,0xFF,0x01,0xFF,0x01, + 0x03,0xFF,0xFF,0x01,0xDF,0x21,0xFF,0x01, + 0xF0,0x30,0x70,0x30,0x62,0x30,0x76,0x38, + 0x6D,0x3B,0x6A,0x2E,0x71,0x20,0x64,0x3B, + 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00, + 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xFB,0xAF, + 0x77,0x10,0x37,0x30,0xA3,0x34,0xCB,0x64, + 0x93,0x8C,0x47,0x38,0x87,0x78,0x17,0xE8, + 0xE0,0x0C,0xCC,0x10,0xF8,0x24,0xD0,0x18, + 0xA0,0x4C,0x93,0x64,0x97,0x68,0xDE,0x28, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0x00,0x0D,0x00,0x31,0x00,0xD1,0x00, + 0x03,0x00,0x0D,0x00,0x31,0x00,0xD1,0x00, + 0x11,0x00,0x01,0x00,0x01,0x00,0x11,0x00, + 0xFF,0x00,0x10,0x00,0x10,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00, + 0xFF,0x00,0x08,0x00,0x08,0x00,0x08,0x00, + 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00, + 0xC0,0x00,0xF0,0x00,0xAC,0x00,0xDF,0x00, + 0xAA,0x00,0xDD,0x00,0xAA,0x00,0xDD,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xC0,0x00,0xF0,0x00,0xAC,0x00,0xDF,0x00, + 0x40,0xBF,0xEE,0x11,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x38,0xC7,0x00,0xFF,0xC7,0x38,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x3D,0xC4,0x05,0xFC,0xC5,0x3C,0xFD,0x04, + 0xFD,0x04,0xFD,0x04,0xFD,0x04,0xFD,0x04, + 0xC0,0xFF,0xFF,0x80,0xFB,0x84,0xFF,0x80, + 0xC0,0xFF,0xFF,0x80,0xFB,0x84,0xFF,0x80, + 0x03,0xFF,0xFF,0x01,0xFF,0x01,0xFF,0x01, + 0x03,0xFF,0xDF,0x21,0xDF,0x21,0xDF,0x21, + 0x60,0x3F,0x60,0x3F,0x60,0x3F,0x60,0x3F, + 0x62,0x3D,0x63,0x3C,0x63,0x3C,0x63,0x3C, + 0xBB,0xEE,0xAB,0xFF,0x82,0xC6,0x39,0x83, + 0xC7,0x82,0xDB,0xA7,0xDA,0xA6,0x92,0xEE, + 0x3F,0xC0,0x7F,0x80,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x0C,0x00,0x0E,0x01,0x07,0x09,0x02,0x07, + 0x00,0x00,0x00,0x00,0x80,0x00,0xC2,0x10, + 0xE6,0x78,0xF5,0x9B,0xFF,0x0E,0xE7,0x1C, + 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00, + 0x47,0x88,0x63,0x9C,0xA7,0xDF,0xFA,0x7F, + 0x00,0x80,0x11,0x80,0x10,0x80,0x01,0x80, + 0x01,0x80,0x01,0x80,0x11,0x80,0x12,0x81, + 0x11,0x00,0x11,0x00,0x11,0x00,0x12,0x01, + 0x19,0x06,0x25,0x1A,0x9C,0x63,0x7F,0x80, + 0x10,0x00,0x10,0x00,0x10,0x00,0x00,0xFF, + 0xEF,0x10,0xEF,0x10,0x00,0xFF,0xBE,0x41, + 0x08,0x00,0x08,0x00,0x08,0x00,0x00,0xFF, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xAA,0x00,0xDD,0x00,0xAA,0x00,0x5D,0x80, + 0x9A,0x60,0xE5,0x18,0xF9,0x06,0xFE,0x01, + 0xAA,0x01,0xDC,0x01,0xAA,0x01,0xDC,0x01, + 0xAA,0x01,0xDC,0x01,0xAA,0x01,0x5C,0x81, + 0xC5,0x32,0x09,0x66,0x6B,0x14,0xEF,0x10, + 0xCF,0x20,0x3F,0x60,0xCF,0x30,0x0F,0x10, + 0xFD,0x04,0xFD,0x04,0xFD,0x04,0xFD,0x04, + 0xFD,0x04,0xFD,0x04,0xFD,0x04,0xFD,0x04, + 0xC0,0xFF,0xFF,0x80,0xF7,0x88,0xFF,0x80, + 0xC0,0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80, + 0x03,0xFF,0xFF,0x01,0xEF,0x11,0xFF,0x01, + 0x03,0xFF,0x7F,0x81,0x7F,0x81,0x7F,0x81, + 0x63,0x3C,0x63,0x3C,0x63,0x3C,0x63,0x3C, + 0x63,0x3C,0x63,0x3C,0x63,0x3C,0x63,0x3C, + 0xEE,0x08,0xEC,0x08,0xCD,0x2C,0xD5,0x26, + 0xC8,0x31,0xE2,0x1C,0xE8,0x17,0xF8,0x07, + 0xAA,0xFE,0xAA,0xFE,0x00,0x44,0x38,0x82, + 0xC6,0x82,0xDA,0xA6,0xDA,0xA6,0xBA,0xEE, + 0xC1,0x00,0xF1,0x00,0xAD,0x00,0xDF,0x00, + 0xAA,0x01,0xDC,0x01,0xAB,0x01,0xDD,0x00, + 0xFC,0x00,0x04,0x00,0x74,0x00,0x04,0x00, + 0xF8,0x04,0xF8,0x04,0xCC,0xFC,0x9F,0xF8, + 0xFF,0x00,0xFF,0x00,0xFE,0x01,0xF0,0x0E, + 0xE0,0x10,0xC0,0x20,0xB0,0x40,0x38,0x40, + 0xFF,0x00,0xFF,0x00,0x0F,0xF0,0x03,0x0C, + 0x01,0x02,0x01,0x02,0x05,0x02,0x0A,0x06, + 0x00,0x00,0xF7,0x00,0xF7,0x00,0xF7,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xC8,0x3F,0x42,0xBD,0x1B,0xE4,0x9B,0x64, + 0xFD,0x02,0xF6,0x09,0xFE,0x09,0x6F,0x98, + 0x00,0xFF,0x11,0xEE,0x39,0xC6,0x7B,0x84, + 0x7F,0x84,0x7F,0x84,0x79,0x86,0x7B,0x86, + 0xCA,0x3D,0x46,0xB9,0x0E,0xF9,0x9E,0x7D, + 0xFD,0x3F,0xBF,0x7F,0xFF,0x7F,0x7F,0xFF, + 0x00,0xFF,0x11,0xEE,0x3B,0xC6,0xD3,0xEE, + 0xE7,0xFC,0xF7,0xFC,0xFD,0xFE,0xFF,0xFE, + 0x1F,0x86,0xBF,0x9C,0xFF,0xE4,0x3F,0x24, + 0x3B,0x24,0x3F,0x22,0x1F,0x12,0x1F,0x12, + 0xFF,0x00,0x81,0x7E,0x81,0x48,0x81,0x48, + 0x81,0x48,0xC0,0x3F,0xC0,0x24,0xC0,0x24, + 0xBE,0x41,0xBF,0x7F,0xE0,0x3F,0xE7,0x3F, + 0xE4,0x3F,0xE3,0x3C,0xE0,0x3F,0xF0,0x1F, + 0xFF,0x00,0xFF,0xFC,0x07,0xFC,0xE7,0xFC, + 0x27,0xDC,0xF7,0x3C,0x37,0xFC,0x0F,0xF8, + 0xFA,0x61,0xFD,0x39,0xFF,0x27,0xFC,0x24, + 0xDC,0x24,0xFC,0x44,0xF8,0x48,0xF8,0x48, + 0xFC,0x03,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xAA,0xFE,0xAA,0xFE,0x00,0x44,0x38,0x82, + 0xC6,0x82,0xDA,0xA6,0xDA,0xA6,0xBA,0xC6, + 0x08,0x00,0x08,0x00,0x08,0x00,0x00,0xFF, + 0xFF,0x00,0xFF,0x00,0xFD,0x02,0xFF,0x00, + 0xCA,0xF9,0x0C,0xF9,0x82,0x39,0xD4,0x09, + 0xAA,0x01,0xDC,0x01,0xAA,0x01,0x5C,0x81, + 0x3F,0x40,0xBF,0x00,0xDF,0x00,0xA3,0x40, + 0xC4,0x38,0xE0,0x1F,0xF8,0x07,0xFF,0x00, + 0x12,0x0E,0xC2,0x3E,0xC1,0x3C,0x82,0x71, + 0x09,0x06,0x03,0xFC,0x0F,0xF0,0xFF,0x00, + 0xEE,0x19,0xC6,0x39,0x42,0xBD,0x04,0xFF, + 0x87,0xFF,0xFF,0x78,0xFE,0x00,0x78,0x00, + 0x33,0xCE,0x31,0xCE,0x31,0xCE,0x33,0xCE, + 0xA3,0xDF,0xCF,0x3C,0xFF,0x00,0x79,0x00, + 0x7D,0xFF,0x6A,0xFF,0xB0,0xFF,0xC0,0x7F, + 0x4F,0xF0,0xFF,0x80,0xFF,0x00,0x78,0x00, + 0x7F,0xFE,0xAF,0xFE,0x1B,0xFE,0x05,0xFE, + 0xE3,0x1F,0xFF,0x00,0xFF,0x00,0x78,0x00, + 0x1D,0x12,0x3C,0x13,0x3E,0x09,0x3F,0x09, + 0x3F,0x09,0x3F,0x07,0x3F,0x00,0x3F,0x00, + 0xFF,0x00,0x1F,0xE0,0xDF,0x20,0xFF,0xFF, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xF8,0x00, + 0xF0,0x1F,0xF0,0x1F,0xFF,0x1F,0xFF,0xF0, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00, + 0x08,0xFF,0x0F,0xF8,0xFF,0xF8,0xFF,0x0F, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00, + 0xFF,0x00,0xF8,0x07,0xFB,0x04,0xFF,0xFF, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x1F,0x00, + 0xB8,0x48,0x3C,0xC8,0x7C,0x90,0xFC,0x90, + 0xFC,0x90,0xFC,0xE0,0xFC,0x00,0xFC,0x00, + 0x1F,0x86,0x3F,0x9C,0xFF,0xE4,0x3F,0x24, + 0x3B,0x24,0x3F,0x22,0x1F,0x12,0x1F,0x12, + 0xFF,0x00,0x81,0x7E,0x81,0x12,0x81,0x12, + 0x81,0x12,0x03,0xFC,0x03,0x24,0x03,0x24, + 0x07,0x02,0x03,0x02,0x03,0x06,0x0F,0x02, + 0x0F,0x01,0x07,0x01,0x01,0x07,0x0D,0x03, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFB,0x00, + 0xCA,0x30,0x1C,0x60,0x68,0x10,0xE4,0x10, + 0xD8,0x20,0x3D,0x60,0xCA,0x30,0x0E,0x10, + 0x10,0x0C,0x2C,0x10,0x18,0x24,0x00,0x38, + 0x30,0x0C,0xEB,0x04,0x77,0x08,0x5E,0x08, + 0x01,0x00,0x0E,0x00,0x10,0x00,0x20,0x00, + 0x70,0x00,0x38,0x40,0x3F,0x40,0x3F,0x40, + 0xF0,0x00,0x0C,0x00,0x02,0x00,0x00,0x02, + 0x04,0x02,0x08,0x06,0x12,0x0E,0xC2,0x3E, + 0x00,0x00,0x00,0x1E,0x1E,0x21,0x33,0x40, + 0x3F,0x21,0x7E,0x7F,0xE5,0x46,0xC7,0x5F, + 0x00,0x78,0x78,0x84,0xCC,0x02,0xF8,0x84, + 0x7C,0xFC,0xF6,0x0E,0x9B,0x06,0xF3,0x0E, + 0xC0,0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80, + 0xC0,0xFF,0xFF,0x80,0xFB,0x84,0xFF,0x80, + 0x03,0xFF,0xFF,0x01,0xDF,0x21,0xFF,0x01, + 0x03,0xFF,0xFF,0x01,0xFF,0x01,0xFF,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, + 0xC8,0x11,0xAC,0x73,0xF4,0xDB,0xEF,0x1F, + 0x1B,0x06,0x0F,0x02,0x07,0x02,0xD3,0x06, + 0xFF,0x0E,0x73,0x9E,0xF3,0xFE,0xD3,0x3E, + 0xFB,0x00,0xFF,0x00,0xFB,0x00,0xFF,0x00, + 0xDF,0x00,0xDF,0x00,0xFB,0x00,0x9A,0x01, + 0xFF,0x00,0x7D,0x00,0x6F,0x00,0xFD,0x00, + 0x6D,0x00,0xEF,0x00,0xFF,0x00,0xD9,0x20, + 0x80,0x00,0x00,0x80,0x80,0xC0,0xDE,0x40, + 0x60,0xC0,0xE0,0x80,0xE0,0x80,0xF0,0x80, + 0x01,0x00,0x00,0x01,0x01,0x03,0xCB,0x02, + 0x03,0x02,0x01,0x01,0x01,0x01,0x01,0x01, + 0x1B,0x10,0x1D,0x30,0x6B,0x10,0x76,0x08, + 0x3B,0x08,0x0E,0x38,0x7C,0x18,0xEA,0x30, + 0xBC,0x0E,0x6C,0x06,0x57,0x08,0x3B,0x0C, + 0x30,0x0E,0x0C,0x10,0x26,0x18,0x10,0x0C, + 0x1F,0x20,0x6F,0x10,0xF1,0x0E,0x7E,0x01, + 0x1F,0x00,0x40,0x00,0x60,0x00,0x20,0x00, + 0xC2,0x3E,0x84,0x7C,0x8E,0x78,0xF8,0xF0, + 0xF6,0x00,0x0E,0x00,0x8C,0x00,0x00,0x00, + 0xC2,0x5F,0xC0,0x5F,0xE0,0x60,0xFC,0x5F, + 0xEF,0x50,0xE0,0x5F,0xDF,0x60,0xBF,0x7F, + 0xFB,0xF6,0xC3,0xFA,0x77,0x06,0x3F,0xFA, + 0xF7,0x0A,0x07,0xFA,0xFB,0x06,0xFD,0xFE, + 0x00,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xC0,0xFF,0xFF,0x80,0xF7,0x88,0xFF,0x80, + 0xC0,0xFF,0xFD,0x82,0xFD,0x82,0xFD,0x82, + 0x03,0xFF,0xFF,0x01,0xEF,0x11,0xFF,0x01, + 0x03,0xFF,0xFF,0x01,0xFF,0x01,0xFF,0x01, + 0x3F,0x00,0x20,0x00,0x2E,0x00,0x20,0x00, + 0x1F,0x20,0x1F,0x20,0x33,0x3F,0xD9,0x1F, + 0x83,0x00,0x8D,0x00,0xB1,0x00,0xD1,0x00, + 0x11,0x80,0x01,0x80,0x81,0x80,0x11,0x00, + 0x13,0xEE,0x3B,0xCE,0x3F,0xC4,0x7F,0x84, + 0x7F,0x84,0x7F,0x84,0x7B,0x86,0x7B,0x86, + 0x22,0xC1,0x08,0xF7,0x80,0x7F,0xCB,0x34, + 0x7F,0x80,0x22,0xC1,0x00,0xFF,0x00,0xFF, + 0x84,0x63,0x84,0x7B,0x81,0x7E,0xD3,0x2C, + 0xFE,0x01,0x44,0x83,0x00,0xFF,0x00,0xFF, + 0xEF,0x90,0xB0,0xC0,0xF0,0x80,0xF0,0x80, + 0xF8,0x80,0xF8,0x80,0x77,0xC8,0xD8,0x60, + 0x3D,0x01,0x03,0x01,0x01,0x01,0x02,0x03, + 0x03,0x02,0x03,0x02,0xB3,0x02,0x0F,0x02, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x0C,0xF3,0xAE,0x50,0xA6,0x00,0x00,0x00, + 0xFD,0x04,0xFF,0x04,0xFF,0x0F,0x00,0xF0, + 0x00,0xC0,0x83,0x40,0xFE,0x21,0x3B,0x3C, + 0x63,0x3C,0xE3,0x3C,0xF1,0xFE,0x0D,0x0E, + 0x02,0x03,0xC2,0x02,0x7E,0x84,0xDC,0x3C, + 0x13,0x9F,0x10,0x9F,0x00,0x9C,0x01,0x90, + 0x01,0x80,0x01,0x80,0x11,0x80,0x12,0x81, + 0xEE,0x19,0xC6,0x39,0x42,0xBD,0x04,0xFF, + 0x87,0xFF,0xFF,0x78,0xFF,0x00,0x8E,0x00, + 0x33,0xCE,0x33,0xCE,0x33,0xCE,0x33,0xCE, + 0x97,0xEE,0xCF,0x3C,0xFE,0x00,0x7C,0x00, + 0x04,0xFB,0x03,0xFC,0x00,0xFF,0x10,0xEF, + 0x90,0x6F,0x52,0x8C,0x7F,0x80,0x47,0x80, + 0xA0,0x5F,0xC0,0x3F,0x00,0xFF,0x04,0xFB, + 0x0D,0xF2,0x4A,0x31,0xFE,0x01,0xE2,0x01, + 0xF8,0x40,0x78,0xC0,0xF8,0x80,0xF0,0x80, + 0xF0,0x00,0xE0,0x00,0xC0,0x00,0x00,0x00, + 0x02,0x03,0x02,0x03,0x06,0x03,0x07,0x01, + 0x07,0x01,0x03,0x00,0x01,0x00,0x00,0x00, + 0x1F,0x10,0x1F,0x10,0x0F,0x09,0x02,0x0F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xC0,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x03,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xF8,0x08,0xF8,0x08,0xF0,0x90,0x40,0xF0, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x02,0x80,0x07,0x80,0x08,0x80,0x70,0x80, + 0x3C,0x80,0x07,0x80,0x78,0x00,0xFF,0x00, + 0x40,0x01,0xE0,0x01,0x10,0x01,0x0E,0x01, + 0x3C,0x01,0xE0,0x01,0x1E,0x00,0xFF,0x00, + 0xBF,0x00,0xCF,0x00,0xF0,0x00,0xFF,0x00, + 0x7F,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00, + 0xFD,0x00,0xF3,0x00,0x0F,0x00,0xFF,0x00, + 0xFE,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x16,0x08,0x14,0x08,0x01,0x0C,0x11,0x06, + 0x02,0x01,0x05,0x00,0x03,0x00,0x05,0x00, + 0x68,0x10,0x28,0x10,0x80,0x30,0x88,0x60, + 0x40,0x80,0xA0,0x00,0xC0,0x00,0xA0,0x00, + 0xC9,0x3E,0x3C,0x03,0x0F,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x73,0xFC,0x3C,0xC0,0xF0,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, + 0x2C,0x10,0x18,0x24,0x00,0x38,0x30,0x0C, + 0x6B,0x04,0xB7,0x08,0x5E,0x08,0x7C,0x0E, + 0x05,0x00,0x03,0x00,0x05,0x00,0x02,0x01, + 0x11,0x06,0x01,0x0C,0x14,0x08,0x16,0x08, + 0x01,0x00,0x28,0x00,0x51,0x00,0x41,0xBE, + 0x0C,0xF3,0xAE,0x50,0xA6,0x00,0x00,0x00, + 0x80,0x00,0x02,0x00,0x55,0x00,0x1E,0xE0, + 0x40,0xBF,0xCC,0x33,0x9C,0x00,0x18,0x00, + 0x01,0x00,0x82,0x00,0x55,0x00,0x9E,0x60, + 0xC0,0x3F,0x4C,0xB3,0x1C,0x00,0x18,0x00, + 0xEC,0x06,0xBC,0x02,0x72,0x04,0xC3,0x1C, + 0xD1,0x2C,0x18,0xE0,0x08,0x60,0x40,0x00, + 0xF3,0x4C,0xF7,0x28,0xEF,0x30,0xFF,0x20, + 0xFF,0x20,0xFA,0x25,0xFE,0x25,0xFF,0x44, + 0xF1,0x0E,0xF1,0x0E,0xF9,0x06,0x7B,0x84, + 0x7F,0x84,0x7F,0x84,0xF9,0x06,0xFB,0x06, + 0xC7,0x38,0xCF,0x30,0x9F,0x60,0xBF,0x40, + 0xFD,0x02,0xF6,0x09,0xFE,0x09,0x7F,0x88, + 0x07,0xF8,0x8F,0x70,0x8F,0x70,0xA7,0x58, + 0xF5,0x0A,0xF6,0x09,0xFE,0x09,0x7F,0x88, + 0xF3,0x0E,0xF3,0x0E,0xFB,0x06,0x7F,0x84, + 0x7F,0x84,0x7F,0x84,0xFF,0x04,0xFB,0x06, + 0xFF,0x44,0xF3,0x4C,0xF1,0x4E,0xF9,0x46, + 0xFB,0x46,0xFB,0x46,0xFB,0x46,0xF2,0x4F, + 0xB3,0x4E,0xF1,0x0E,0xB1,0x4E,0xB8,0x47, + 0xBA,0x47,0x6A,0x97,0x62,0x9F,0xF2,0x0F, + 0xFF,0x08,0xE7,0x18,0xE3,0x1C,0xF3,0x0C, + 0xF7,0x0C,0xF7,0x0C,0xF5,0x0E,0xE4,0x1F, + 0xB3,0x4E,0xF1,0x0E,0xB1,0x4E,0xB8,0x47, + 0xDA,0x27,0xEA,0x17,0xE2,0x1F,0xC2,0x3F, + 0xFF,0x08,0xE7,0x18,0x63,0x9C,0xB3,0x4C, + 0x77,0x8C,0xF7,0x0C,0xD5,0x2E,0xC4,0x3F, + 0xB3,0x4E,0xF3,0x0E,0xB3,0x4E,0xBB,0x46, + 0xDB,0x26,0xEB,0x16,0xF3,0x1E,0x73,0x9E, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x40,0xBF,0xCC,0x33,0x9C,0x00,0x18,0x00, + 0x38,0xC7,0x00,0xFF,0x07,0xF8,0x3F,0xC0, + 0x7F,0x80,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xC0,0x3F,0xC0,0x20,0xCE,0x20,0xC0,0x20, + 0xDF,0x20,0xDF,0x20,0xF3,0x3F,0x19,0xDF, + 0x7C,0x83,0x71,0x8C,0x41,0xB0,0x11,0xC0, + 0x11,0x80,0x01,0x80,0x81,0x80,0x11,0x00, + 0x00,0xFF,0x10,0x00,0x10,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00, + 0x00,0xFF,0x08,0x00,0x08,0x00,0x08,0x00, + 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00, + 0x3F,0xC0,0xCF,0x30,0xA3,0x0C,0xDC,0x03, + 0xAA,0x00,0xDD,0x00,0xAA,0x00,0xDD,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x3F,0xC0,0xCF,0x30,0xA3,0x0C,0xDC,0x03, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x9F,0x60,0x8F,0x30,0x2F,0x10,0x77,0x10, + 0xA0,0x00,0xC0,0x00,0xA0,0x00,0x40,0x80, + 0x88,0x60,0x80,0x30,0x28,0x10,0x68,0x10, + 0x10,0x0C,0x2C,0x10,0x18,0x24,0x00,0x38, + 0x30,0x0C,0x6B,0x04,0x77,0x08,0x5E,0x08, + 0x3C,0x0E,0x6C,0x06,0x57,0x08,0x3B,0x0C, + 0x30,0x0E,0x0C,0x10,0x26,0x18,0x10,0x0C, + 0x00,0x00,0x80,0x00,0xC2,0x10,0xD6,0x78, + 0x6C,0x9B,0xFD,0x0E,0xDF,0x00,0xF5,0x00, + 0x00,0x00,0x00,0x00,0x06,0x00,0x47,0x88, + 0xEB,0x9C,0x3C,0xDF,0xBF,0x78,0xAB,0x00 +}; + +/* End of BIGMAP_TILES.C */ diff --git a/gbdk-lib/examples/ap/large_map/bigmap_tiles.h b/gbdk-lib/examples/ap/large_map/bigmap_tiles.h @@ -0,0 +1,107 @@ +/* + + BIGMAP_TILES.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 240 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + +#ifndef __bigmap_tiles_h_INCLUDE +#define __bigmap_tiles_h_INCLUDE + +/* Bank of tiles. */ +#define bigmap_tilesBank 0 + +/* Super Gameboy palette 0 */ +#define bigmap_tilesSGBPal0c0 0 +#define bigmap_tilesSGBPal0c1 0 +#define bigmap_tilesSGBPal0c2 10240 +#define bigmap_tilesSGBPal0c3 400 + +/* Super Gameboy palette 1 */ +#define bigmap_tilesSGBPal1c0 6076 +#define bigmap_tilesSGBPal1c1 8935 +#define bigmap_tilesSGBPal1c2 6596 +#define bigmap_tilesSGBPal1c3 5344 + +/* Super Gameboy palette 2 */ +#define bigmap_tilesSGBPal2c0 6076 +#define bigmap_tilesSGBPal2c1 8935 +#define bigmap_tilesSGBPal2c2 6596 +#define bigmap_tilesSGBPal2c3 5344 + +/* Super Gameboy palette 3 */ +#define bigmap_tilesSGBPal3c0 6076 +#define bigmap_tilesSGBPal3c1 8935 +#define bigmap_tilesSGBPal3c2 6596 +#define bigmap_tilesSGBPal3c3 5344 + +/* Gameboy Color palette 0 */ +#define bigmap_tilesCGBPal0c0 0 +#define bigmap_tilesCGBPal0c1 10570 +#define bigmap_tilesCGBPal0c2 20083 +#define bigmap_tilesCGBPal0c3 32767 + +/* Gameboy Color palette 1 */ +#define bigmap_tilesCGBPal1c0 6076 +#define bigmap_tilesCGBPal1c1 8935 +#define bigmap_tilesCGBPal1c2 6596 +#define bigmap_tilesCGBPal1c3 5344 + +/* Gameboy Color palette 2 */ +#define bigmap_tilesCGBPal2c0 6076 +#define bigmap_tilesCGBPal2c1 8935 +#define bigmap_tilesCGBPal2c2 6596 +#define bigmap_tilesCGBPal2c3 5344 + +/* Gameboy Color palette 3 */ +#define bigmap_tilesCGBPal3c0 6076 +#define bigmap_tilesCGBPal3c1 8935 +#define bigmap_tilesCGBPal3c2 6596 +#define bigmap_tilesCGBPal3c3 5344 + +/* Gameboy Color palette 4 */ +#define bigmap_tilesCGBPal4c0 6076 +#define bigmap_tilesCGBPal4c1 8935 +#define bigmap_tilesCGBPal4c2 6596 +#define bigmap_tilesCGBPal4c3 5344 + +/* Gameboy Color palette 5 */ +#define bigmap_tilesCGBPal5c0 6076 +#define bigmap_tilesCGBPal5c1 8935 +#define bigmap_tilesCGBPal5c2 6596 +#define bigmap_tilesCGBPal5c3 5344 + +/* Gameboy Color palette 6 */ +#define bigmap_tilesCGBPal6c0 6076 +#define bigmap_tilesCGBPal6c1 8935 +#define bigmap_tilesCGBPal6c2 6596 +#define bigmap_tilesCGBPal6c3 5344 + +/* Gameboy Color palette 7 */ +#define bigmap_tilesCGBPal7c0 6076 +#define bigmap_tilesCGBPal7c1 8935 +#define bigmap_tilesCGBPal7c2 6596 +#define bigmap_tilesCGBPal7c3 5344 +/* Start of tile array. */ +extern const unsigned char bigmap_tiles[]; + +#endif + +/* End of BIGMAP_TILES.H */ diff --git a/gbdk-lib/examples/ap/large_map/large_map.c b/gbdk-lib/examples/ap/large_map/large_map.c @@ -0,0 +1,96 @@ +#include <gb/gb.h> +#include <stdint.h> + +#include "bigmap_map.h" +#include "bigmap_tiles.h" + +#define camera_max_y ((bigmap_mapHeight - 18) * 8) +#define camera_max_x ((bigmap_mapWidth - 20) * 8) + +#define MIN(A,B) ((A)<(B)?(A):(B)) + +uint8_t joy; + +// current and old positions of the camera in pixels +uint16_t camera_x, camera_y, old_camera_x, old_camera_y; +// current and old position of the map in tiles +uint8_t map_pos_x, map_pos_y, old_map_pos_x, old_map_pos_y; +// redraw flag, indicates that camera position was changed +uint8_t redraw; + +void set_camera() { + // update hardware scroll position + SCY_REG = camera_y; SCX_REG = camera_x; + // up or down + map_pos_y = (uint8_t)(camera_y >> 3u); + if (map_pos_y != old_map_pos_y) { + if (camera_y < old_camera_y) { + set_bkg_submap(map_pos_x, map_pos_y, MIN(21u, bigmap_mapWidth-map_pos_x), 1, bigmap_map, bigmap_mapWidth); + } else { + if ((bigmap_mapHeight - 18u) > map_pos_y) set_bkg_submap(map_pos_x, map_pos_y + 18u, MIN(21u, bigmap_mapWidth-map_pos_x), 1, bigmap_map, bigmap_mapWidth); + } + old_map_pos_y = map_pos_y; + } + // left or right + map_pos_x = (uint8_t)(camera_x >> 3u); + if (map_pos_x != old_map_pos_x) { + if (camera_x < old_camera_x) { + set_bkg_submap(map_pos_x, map_pos_y, 1, MIN(19u, bigmap_mapHeight - map_pos_y), bigmap_map, bigmap_mapWidth); + } else { + if ((bigmap_mapWidth - 20u) > map_pos_x) set_bkg_submap(map_pos_x + 20u, map_pos_y, 1, MIN(19u, bigmap_mapHeight - map_pos_y), bigmap_map, bigmap_mapWidth); + } + old_map_pos_x = map_pos_x; + } + // set old camera position to current camera position + old_camera_x = camera_x, old_camera_y = camera_y; +} + +void main(){ + DISPLAY_OFF; + SHOW_BKG; + set_bkg_data(0, 241u, bigmap_tiles); + + map_pos_x = map_pos_y = 0; + old_map_pos_x = old_map_pos_y = 255; + set_bkg_submap(map_pos_x, map_pos_y, 20, 18, bigmap_map, bigmap_mapWidth); + DISPLAY_ON; + + camera_x = camera_y = 0; + old_camera_x = camera_x; old_camera_y = camera_y; + + redraw = FALSE; + + SCX_REG = camera_x; SCY_REG = camera_y; + while (TRUE) { + joy = joypad(); + // up or down + if (joy & J_UP) { + if (camera_y) { + camera_y--; + redraw = TRUE; + } + } else if (joy & J_DOWN) { + if (camera_y < camera_max_y) { + camera_y++; + redraw = TRUE; + } + } + // left or right + if (joy & J_LEFT) { + if (camera_x) { + camera_x--; + redraw = TRUE; + } + } else if (joy & J_RIGHT) { + if (camera_x < camera_max_x) { + camera_x++; + redraw = TRUE; + } + } + if (redraw) { + wait_vbl_done(); + set_camera(); + redraw = FALSE; + } else wait_vbl_done(); + } +} + diff --git a/gbdk-lib/examples/ap/lcd_isr_wobble/Makefile b/gbdk-lib/examples/ap/lcd_isr_wobble/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = lcd_isr_wobble.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/lcd_isr_wobble/lcd_isr_wobble.c b/gbdk-lib/examples/ap/lcd_isr_wobble/lcd_isr_wobble.c @@ -0,0 +1,28 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +#include <gb/bgb_emu.h> + +const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0}; +const uint8_t * scanline_offsets = scanline_offsets_tbl; + +void scanline_isr() { + SCX_REG = scanline_offsets[LY_REG & (uint8_t)7]; +} + + +void main() { + printf("This is\na wobble\ntest\nfor DMG\n|\n|\n|\n|\n|"); + + CRITICAL { + STAT_REG = STATF_MODE01 | STATF_MODE00; + add_LCD(scanline_isr); + } + set_interrupts(VBL_IFLAG | LCD_IFLAG); + + while (1) { + wait_vbl_done(); + scanline_offsets = &scanline_offsets_tbl[(uint8_t)(sys_time >> 2) & 0x07u]; + } +} + diff --git a/gbdk-lib/examples/ap/linkerfile/Makefile b/gbdk-lib/examples/ap/linkerfile/Makefile @@ -0,0 +1,68 @@ +# +# A Makefile that compiles all .c and .s files in "src" and "res" +# subdirectories and places the output in a "obj" subdirectory +# + +# If you move this project you can change the directory +# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" +GBDK_HOME = ../../../ + +LCC = $(GBDK_HOME)bin/lcc + +# You can set flags for LCC here +# For example, you can uncomment the line below to turn on debug output +LCCFLAGS = -mgbz80:ap +# LCCFLAGS += -debug +# LCCFLAGS += -v + +# You can set the name of the .pocket ROM file here +PROJECTNAME = Example + +SRCDIR = src +OBJDIR = obj +RESDIR = res +BINS = $(OBJDIR)/$(PROJECTNAME).pocket +CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c))) +ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s))) +OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o) + +all: prepare $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile .c files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.c + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# Compile .c files in "res/" to .o object files +$(OBJDIR)/%.o: $(RESDIR)/%.c + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# Compile .s assembly files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.s + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# If needed, compile .c files i n"src/" to .s assembly files +# (not required if .c is compiled directly to .o) +$(OBJDIR)/%.s: $(SRCDIR)/%.c + $(LCC) $(LCCFLAGS) -S -o $@ $< + + +$(OBJDIR)/linkfile.lk: $(OBJS) + rm -f $(OBJDIR)/linkfile.lk + $(foreach O,$(OBJS),echo $O >>$@) + +# Link the compiled object files (via linkerfile) into a .pocket ROM file +$(BINS): $(OBJDIR)/linkfile.lk + $(LCC) $(LCCFLAGS) -o $(BINS) -Wl-f$< + +prepare: + mkdir -p $(OBJDIR) + mkdir -p $(RESDIR) + +clean: +# rm -f *.pocket *.ihx *.cdb *.adb *.noi *.map + rm -f $(OBJDIR)/*.* + diff --git a/gbdk-lib/examples/ap/linkerfile/Readme.md b/gbdk-lib/examples/ap/linkerfile/Readme.md @@ -0,0 +1,18 @@ + +# Example of how to use a linkerfile + +A linkerfile allows storing all the object files to be linked in a +file which is passed to the linker instead of a list of filenames on +the command line. This may be useful if your project has filenames +that use up more length than will fit on the command line for Windows +(8191 chars max). + +The typical extension for the linkerfile is ".lk". + +It is passed to sdldgb through lcc using `-Wl-f<pathtolinkerfile>` +If calling sdldgb directly, use `-f<pathtolinkerfile>` + +The Makefile is configured to store all the compiled ".o" object files +into `obj/linkerfile.lk`. + + diff --git a/gbdk-lib/examples/ap/linkerfile/src/main.c b/gbdk-lib/examples/ap/linkerfile/src/main.c @@ -0,0 +1,15 @@ +#include <gb/gb.h> +#include <stdint.h> + + +void main(void) +{ + // Loop forever + while(1) { + + // Game main loop processing goes here + + // Done processing, yield CPU and wait for start of next frame + wait_vbl_done(); + } +} diff --git a/gbdk-lib/examples/ap/metasprites/Makefile b/gbdk-lib/examples/ap/metasprites/Makefile @@ -0,0 +1,36 @@ +LCC = ../../../bin/lcc +PNG2MTSPR = ../../../bin/png2mtspr + +CFLAGS = -mgbz80:ap -Wl-j -Wm-yS + +# Output name for compiled ROM +BINS = metasprites.pocket + +# Add entries here to have them converted into metasprites +PNGSOURCES = sprite.png +PNG_CSOURCES = $(PNGSOURCES:%.png=%.c) +PNG_CHEADERS = $(PNGSOURCES:%.png=%.h) + +# List of all C source files except those generated by png2mtspr +CSOURCES = $(filter-out $(PNGSOURCES:%.png=%.c), $(wildcard *.c)) + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Use png2mtspr to convert the png into C formatted metasprite data +# -sh 48 : Sets sprite height to 48 (width remains automatic) +# -spr8x16 : Use 8x16 hardware sprites +# -c ... : Set C output file +%.c: %.png + $(PNG2MTSPR) $< -sh 48 -spr8x16 -c $@ + +# Compile all C sources, including converted png metasprites +$(BINS): $(CSOURCES) $(PNG_CSOURCES) + $(LCC) $(CFLAGS) -o $(BINS) $(CSOURCES) $(PNG_CSOURCES) + + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm $(PNG_CHEADERS) $(PNG_CSOURCES) diff --git a/gbdk-lib/examples/ap/metasprites/Readme.md b/gbdk-lib/examples/ap/metasprites/Readme.md @@ -0,0 +1,20 @@ + +Metasprite Example +================== + +Demonstrates using the metasprite features to move and animate a large sprite. + +* Press A button to show / hide the metasprite +* Press B button to cycle through the metasprite animations +* Press SELECT button to cycle the metasprite through Normal / Flip-Y / Flip-XY / Flip-X +* Up / Down / Left / Right to move the metasprite + +In this example the move_metasprite...() functions are called every +frame to simplify the example code, regardless of whether the updates +are needed or not. + +In a real game it would be better to only call them if something changed +(such as movement or rotation) since that reduces CPU usage on frames where +the updates aren't required. + + diff --git a/gbdk-lib/examples/ap/metasprites/metasprites.c b/gbdk-lib/examples/ap/metasprites/metasprites.c @@ -0,0 +1,153 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <gb/sgb.h> +#include <gb/metasprites.h> + +#include "sprite.h" + +const unsigned char pattern[] = {0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x01,0x01}; + +joypads_t joypads; + +#define ACC_X 1 +#define ACC_Y 2 + +// The metasprite will be built starting with hardware sprite zero (the first) +#define SPR_NUM_START 0 + +// Metasprite tiles are loaded into VRAM starting at tile number 0 +#define TILE_NUM_START 0 + +// sprite coords +uint16_t PosX, PosY; +int16_t SpdX, SpdY; +uint8_t PosF; +uint8_t hide, jitter; +uint8_t idx, rot; + +// main funxction +void main(void) { + // init palettes + BGP_REG = OBP0_REG = 0xE4; + OBP1_REG = 0xE0; + + // Fill the screen background with a single tile pattern + fill_bkg_rect(0, 0, 20, 18, 0); + set_bkg_data(0, 1, pattern); + + // Load metasprite tile data into VRAM + set_sprite_data(TILE_NUM_START, sizeof(sprite_data) >> 4, sprite_data); + + // show bkg and sprites + SHOW_BKG; SHOW_SPRITES; + + // Check what size hardware sprite the metasprite is using (from sprite.h) + #if sprite_TILE_H == 16 + SPRITES_8x16; + #else + SPRITES_8x8; + #endif + + // init 1 joypad + joypad_init(1, &joypads); + + // Set initial position, zero out speed + PosX = PosY = 64 << 4; + SpdX = SpdY = 0; + + hide = 0; jitter = 0; idx = 0; rot = 0; + + while(1) { + // poll joypads + joypad_ex(&joypads); + + PosF = 0; + // game object + if (joypads.joy0 & J_UP) { + SpdY -= 2; + if (SpdY < -32) SpdY = -32; + PosF |= ACC_Y; + } else if (joypads.joy0 & J_DOWN) { + SpdY += 2; + if (SpdY > 32) SpdY = 32; + PosF |= ACC_Y; + } + + if (joypads.joy0 & J_LEFT) { + SpdX -= 2; + if (SpdX < -32) SpdX = -32; + PosF |= ACC_X; + } else if (joypads.joy0 & J_RIGHT) { + SpdX += 2; + if (SpdX > 32) SpdX = 32; + PosF |= ACC_X; + } + + + // Press A button to show/hide metasprite + if ((joypads.joy0 & J_A) && (!jitter)) { + hide = (!hide); + jitter = 20; + } + + // Press B button to cycle through metasprite animations + if ((joypads.joy0 & J_B) && (!jitter) && (!hide)) { + idx++; if (idx >= (sizeof(sprite_metasprites) >> 1)) idx = 0; + jitter = 10; + } + + // Press SELECT button to cycle metasprite through Normal/Flip-Y/Flip-XY/Flip-X + if ((joypads.joy0 & J_SELECT) && (!jitter) && (!hide)) { + rot++; rot &= 3; + jitter = 20; + } + + // Hide/Animate/Flip input throttling + if (jitter) jitter--; + + PosX += SpdX, PosY += SpdY; + + uint8_t hiwater = 0; + + // NOTE: In a real game it would be better to only call the move_metasprite..() + // functions if something changed (such as movement or rotation). That + // reduces CPU usage on frames that don't need udpates. + // + // In this example they are called every frame to simplify the example code + + // Hide the metasprite or move it & apply any rotation settings + if (hide) + hide_metasprite(sprite_metasprites[idx], SPR_NUM_START); + else + switch (rot) { + case 0: hiwater = move_metasprite (sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4)); break; + case 1: hiwater = move_metasprite_hflip (sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4)); break; + case 2: hiwater = move_metasprite_hvflip(sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4)); break; + case 3: hiwater = move_metasprite_vflip (sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4)); break; + }; + + // Hide rest of the hardware sprites, because amount of sprites differ between animation frames. + hide_sprites_range(hiwater, 40); + + // Y Axis: update velocity (reduce speed) if no U/D button pressed + if (!(PosF & ACC_Y)) { + if (SpdY != 0) { + if (SpdY > 0) SpdY--; + else SpdY ++; + } + } + + // X Axis: update velocity (reduce speed) if no L/R button pressed + if (!(PosF & ACC_X)) { + if (SpdX != 0) { + if (SpdX > 0) SpdX--; + else SpdX ++; + } + } + + + // wait for VBlank to slow down everything and reduce cpu use when idle + wait_vbl_done(); + } +} + diff --git a/gbdk-lib/examples/ap/metasprites/sprite.png b/gbdk-lib/examples/ap/metasprites/sprite.png Binary files differ. diff --git a/gbdk-lib/examples/ap/paint/Makefile b/gbdk-lib/examples/ap/paint/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = paint.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/paint/paint.c b/gbdk-lib/examples/ap/paint/paint.c @@ -0,0 +1,528 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <gb/drawing.h> + +#define NB_TOOLS 18 +#define NB_DATA_TILES 48 + +#define ARROW 0 +#define PEN 1 +#define BRUSH 2 +#define FILL 3 +#define ERASER 4 +#define CROSS 5 + +#define UNSELECTED 0 +#define SELECTED 1 + +#define FIRST_TOOL 0 +#define LAST_TOOL 9 +#define FIRST_COLOR 10 +#define LAST_COLOR 13 +#define FIRST_MODE 14 +#define LAST_MODE 17 + +typedef struct icon_info_ +{ + uint8_t data_idx; /* Index of data in the data array */ + uint8_t x, y, w, h; /* Position and size (in tiles) */ + uint8_t up, down, left, right; /* Index of next icons (for cursor movements) */ + uint8_t cursor; /* Cursor associated with icon */ +} icon_info; + +typedef struct cursor_info_ +{ + uint8_t data_idx; /* Index of data in the data array */ + uint8_t w, h; /* Size (in tiles) */ + uint8_t hot_x, hot_y; /* Position of hot point, relatice to top-left of sprite (in pixels) */ +} cursor_info; + +const icon_info icons[] = +{ + /* Pen */ + { 0, 0, 0, 2, 2, 10, 2, 1, 1, 1 }, /* 0 */ + /* Brush */ + { 4, 2, 0, 2, 2, 14, 3, 0, 0, 2 }, /* 1 */ + /* Fill */ + { 8, 0, 2, 2, 2, 0, 4, 3, 3, 3 }, /* 2 */ + /* Eraser */ + { 12, 2, 2, 2, 2, 1, 5, 2, 2, 4 }, /* 3 */ + /* Line */ + { 16, 0, 4, 2, 2, 2, 6, 5, 5, 5 }, /* 4 */ + /* Line */ + { 20, 2, 4, 2, 2, 3, 7, 4, 4, 5 }, /* 5 */ + /* Rectangle */ + { 24, 0, 6, 2, 2, 4, 8, 7, 7, 5 }, /* 6 */ + /* Oval */ + { 28, 2, 6, 2, 2, 5, 9, 6, 6, 5 }, /* 7 */ + /* Filled rectangle */ + { 32, 0, 8, 2, 2, 6, 10, 9, 9, 5 }, /* 8 */ + /* Filled oval */ + { 36, 2, 8, 2, 2, 7, 14, 8, 8, 5 }, /* 9 */ + /* Color */ + { 40, 0, 10, 1, 1, 8, 11, 16, 12, 0 }, /* 10 */ + { 41, 0, 11, 1, 1, 10, 0, 17, 13, 0 }, /* 11 */ + { 42, 1, 10, 1, 1, 8, 13, 10, 14, 0 }, /* 12 */ + { 43, 1, 11, 1, 1, 12, 0, 11, 15, 0 }, /* 13 */ + /* Mode */ + { 44, 2, 10, 1, 1, 9, 15, 12, 16, 0 }, /* 14 */ + { 45, 2, 11, 1, 1, 14, 1, 13, 17, 0 }, /* 15 */ + { 46, 3, 10, 1, 1, 9, 17, 14, 10, 0 }, /* 16 */ + { 47, 3, 11, 1, 1, 16, 1, 15, 11, 0 } /* 17 */ +}; + +const unsigned char data[NB_DATA_TILES][0x10] = +{ + /* Pen */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01 }, + { 0x7E,0x02,0x7D,0x05,0x7B,0x0A,0x77,0x14,0x7F,0x18,0x7F,0x27,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x0D,0xF6,0x15,0xEE,0x29,0xDE,0x51,0xBE,0xA1,0x7E,0x41 }, + { 0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0x01,0x00,0xFF }, + /* Brush */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01 }, + { 0x7E,0x02,0x7D,0x0D,0x7F,0x1E,0x7F,0x1E,0x7F,0x1D,0x7F,0x11,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x0D,0xF6,0x15,0xEE,0x29,0xDE,0x51,0xBE,0xA1,0x7E,0x41 }, + { 0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0xFD,0xFE,0x01,0x00,0xFF }, + /* Fill */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01,0x7F,0x02,0x7E,0x0C,0x7D,0x18,0x7E,0x1D }, + { 0x7F,0x1B,0x7F,0x19,0x7F,0x18,0x7F,0x08,0x7F,0x08,0x7F,0x08,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x81,0xFE,0x41,0x7E,0x21,0xBE,0x71,0x5E,0xE9,0xAE,0xC5 }, + { 0x5E,0x89,0xBE,0x11,0xFE,0xA1,0xFE,0x41,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x00,0xFF }, + /* Eraser */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01,0x7E,0x02,0x7C,0x04 }, + { 0x78,0x08,0x7F,0x1F,0x71,0x11,0x7F,0x1F,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xF9,0x1E,0x19,0x2E,0x29,0x5E,0x51 }, + { 0xBE,0xA1,0x7E,0x41,0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x00,0xFF }, + /* Line */ + { 0x00,0x00,0x7F,0x00,0x7F,0x20,0x7F,0x10,0x7F,0x08,0x7F,0x04,0x7F,0x02,0x7F,0x01 }, + { 0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01 }, + { 0xFE,0x81,0xFE,0x41,0xFE,0x21,0xFE,0x11,0xFE,0x09,0xFE,0x05,0xFE,0x01,0x00,0xFF }, + /* Arc */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x1E,0x7F,0x01,0x7F,0x00,0x7F,0x00,0x7F,0x00 }, + { 0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x81,0xFE,0x41,0xFE,0x21,0xFE,0x11 }, + { 0xFE,0x11,0xFE,0x09,0xFE,0x09,0xFE,0x09,0xFE,0x09,0xFE,0x01,0xFE,0x01,0x00,0xFF }, + /* Rectangle */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x3F,0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x20 }, + { 0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x3F,0x7F,0x00,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0x05 }, + { 0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0xFD,0xFE,0x01,0xFE,0x01,0x00,0xFF }, + /* Oval */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x03,0x7F,0x0C,0x7F,0x10,0x7F,0x20,0x7F,0x20 }, + { 0x7F,0x20,0x7F,0x20,0x7F,0x10,0x7F,0x0C,0x7F,0x03,0x7F,0x00,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xC1,0xFE,0x31,0xFE,0x09,0xFE,0x05,0xFE,0x05 }, + { 0xFE,0x05,0xFE,0x05,0xFE,0x09,0xFE,0x31,0xFE,0xC1,0xFE,0x01,0xFE,0x01,0x00,0xFF }, + /* Filled rectangle */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x3F,0x6A,0x3F,0x75,0x3F,0x6A,0x3F,0x75,0x3F }, + { 0x6A,0x3F,0x75,0x3F,0x6A,0x3F,0x75,0x3F,0x7F,0x3F,0x7F,0x00,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xAE,0xFD,0x56,0xFD,0xAE,0xFD,0x56,0xFD }, + { 0xAE,0xFD,0x56,0xFD,0xAE,0xFD,0x56,0xFD,0xFE,0xFD,0xFE,0x01,0xFE,0x01,0x00,0xFF }, + /* Filled oval */ + { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x03,0x7E,0x0F,0x75,0x1F,0x6A,0x3F,0x75,0x3F }, + { 0x6A,0x3F,0x75,0x3F,0x7A,0x1F,0x7D,0x0F,0x7F,0x03,0x7F,0x00,0x7F,0x00,0x00,0x7F }, + { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xC1,0xBE,0xF1,0x5E,0xF9,0xAE,0xFD,0x56,0xFD }, + { 0xAE,0xFD,0x56,0xFD,0xAE,0xF9,0x7E,0xF1,0xFE,0xC1,0xFE,0x01,0xFE,0x01,0x00,0xFF }, + /* Color */ + { 0x00,0x00,0x7F,0x7F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 }, + { 0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x7F,0x7F,0x00,0x7F }, + { 0x00,0x00,0xFE,0xFF,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03 }, + { 0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0x00,0xFF }, + /* Mode */ + { 0x00,0x00,0x7F,0x00,0x7F,0x0C,0x7F,0x10,0x7F,0x08,0x7F,0x04,0x7F,0x18,0x7F,0x00 }, + { 0x7F,0x00,0x7F,0x08,0x7F,0x14,0x7F,0x14,0x7F,0x14,0x7F,0x08,0x7F,0x00,0x00,0x7F }, + { 0x00,0x01,0xFE,0x01,0xFE,0x29,0xFE,0x29,0xFE,0x11,0xFE,0x29,0xFE,0x29,0xFE,0x01 }, + { 0xFE,0x01,0xFE,0x11,0xFE,0x29,0xFE,0x39,0xFE,0x29,0xFE,0x29,0xFE,0x01,0x00,0xFF } +}; + +const unsigned char selected_data[NB_DATA_TILES][0x10] = +{ + /* Pen */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE }, + { 0x81,0xFD,0x82,0xFA,0x84,0xF5,0x88,0xEB,0x80,0xE7,0x80,0xD8,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xF2,0x09,0xEA,0x11,0xD6,0x21,0xAE,0x41,0x5E,0x81,0xBE }, + { 0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0xFE,0xFF,0x00 }, + /* Brush */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE }, + { 0x81,0xFD,0x82,0xF2,0x80,0xE1,0x80,0xE1,0x80,0xE2,0x80,0xEE,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xF2,0x09,0xEA,0x11,0xD6,0x21,0xAE,0x41,0x5E,0x81,0xBE }, + { 0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0x02,0x01,0xFE,0xFF,0x00 }, + /* Fill */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE,0x80,0xFD,0x81,0xF3,0x82,0xE7,0x81,0xE2 }, + { 0x80,0xE4,0x80,0xE7,0x80,0xE7,0x80,0xF7,0x80,0xF7,0x80,0xF7,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0x7E,0x01,0xBE,0x81,0xDE,0x41,0x8E,0xA1,0x16,0x51,0x3A }, + { 0xA1,0x76,0x41,0xEE,0x01,0x5E,0x01,0xBE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFF,0x00 }, + /* Eraser */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE,0x81,0xFD,0x83,0xFB }, + { 0x87,0xF7,0x80,0xE0,0x8E,0xEE,0x80,0xE0,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x06,0xE1,0xE6,0xD1,0xD6,0xA1,0xAE }, + { 0x41,0x5E,0x81,0xBE,0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFF,0x00 }, + /* Line */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xDF,0x80,0xEF,0x80,0xF7,0x80,0xFB,0x80,0xFD,0x80,0xFE }, + { 0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE }, + { 0x01,0x7E,0x01,0xBE,0x01,0xDE,0x01,0xEE,0x01,0xF6,0x01,0xFA,0x01,0xFE,0xFF,0x00 }, + /* Arc */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xE1,0x80,0xFE,0x80,0xFF,0x80,0xFF,0x80,0xFF }, + { 0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x7E,0x01,0xBE,0x01,0xDE,0x01,0xEE }, + { 0x01,0xEE,0x01,0xF6,0x01,0xF6,0x01,0xF6,0x01,0xF6,0x01,0xFE,0x01,0xFE,0xFF,0x00 }, + /* Rectangle */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xC0,0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xDF }, + { 0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xC0,0x80,0xFF,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0xFA }, + { 0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0x02,0x01,0xFE,0x01,0xFE,0xFF,0x00 }, + /* Oval */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFC,0x80,0xF3,0x80,0xEF,0x80,0xDF,0x80,0xDF }, + { 0x80,0xDF,0x80,0xDF,0x80,0xEF,0x80,0xF3,0x80,0xFC,0x80,0xFF,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x3E,0x01,0xCE,0x01,0xF6,0x01,0xFA,0x01,0xFA }, + { 0x01,0xFA,0x01,0xFA,0x01,0xF6,0x01,0xCE,0x01,0x3E,0x01,0xFE,0x01,0xFE,0xFF,0x00 }, + /* Filled rectangle */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0 }, + { 0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x80,0xC0,0x80,0xFF,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02 }, + { 0xF9,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02,0x01,0x02,0x01,0xFE,0x01,0xFE,0xFF,0x00 }, + /* Filled oval */ + { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFC,0x83,0xF0,0x8F,0xE0,0x9F,0xC0,0x9F,0xC0 }, + { 0x9F,0xC0,0x9F,0xC0,0x8F,0xE0,0x83,0xF0,0x80,0xFC,0x80,0xFF,0x80,0xFF,0xFF,0x80 }, + { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x3E,0xC1,0x0E,0xF1,0x06,0xF9,0x02,0xF9,0x02 }, + { 0xF9,0x02,0xF9,0x02,0xF1,0x06,0xC1,0x0E,0x01,0x3E,0x01,0xFE,0x01,0xFE,0xFF,0x00 }, + /* Color */ + { 0x00,0x00,0x7F,0x7F,0x61,0x61,0x52,0x52,0x4C,0x4C,0x4C,0x4C,0x52,0x52,0x61,0x61 }, + { 0x40,0x5E,0x40,0x6D,0x40,0x73,0x40,0x73,0x40,0x6D,0x40,0x5E,0x7F,0x7F,0x00,0x7F }, + { 0x00,0x00,0xFE,0xFF,0xFE,0x87,0xFE,0x4B,0xFE,0x33,0xFE,0x33,0xFE,0x4B,0xFE,0x87 }, + { 0x7A,0x7B,0xB6,0xB7,0xCE,0xCF,0xCE,0xCF,0xB6,0xB7,0x7A,0x7B,0xFE,0xFF,0x00,0xFF }, + /* Mode */ + { 0x00,0x00,0x7F,0x7F,0x73,0x73,0x6F,0x6F,0x77,0x77,0x7B,0x7B,0x67,0x67,0x7F,0x7F }, + { 0x7F,0x7F,0x77,0x77,0x6B,0x6B,0x6B,0x6B,0x6B,0x6B,0x77,0x77,0x7F,0x7F,0x00,0x7F }, + { 0x00,0x01,0xFE,0xFF,0xD6,0xD7,0xD6,0xD7,0xEE,0xEF,0xD6,0xD7,0xD6,0xD7,0xFE,0xFF }, + { 0xFE,0xFF,0xEE,0xEF,0xD6,0xD7,0xC6,0xC7,0xD6,0xD7,0xD6,0xD7,0xFE,0xFF,0x00,0xFF } +}; + +const cursor_info cursors[] = +{ + /* Arrow */ + { 0, 1, 1, 0, 0 }, + /* Pen */ + { 1, 2, 2, 0, 15 }, + /* Brush */ + { 5, 2, 2, 0, 15 }, + /* Fill */ + { 9, 2, 2, 2, 15 }, + /* Eraser */ + { 13, 2, 2, 0, 15 }, + /* Cross */ + { 17, 2, 2, 5, 10 } +}; + +const unsigned char cursors_data[][0x10] = { + /* Arrow */ + { 0xFF,0x00,0xFF,0x7E,0xFF,0x7C,0xFE,0x78,0xFF,0x7C,0xFF,0x6E,0xFF,0x46,0xEF,0x00 }, + /* Pen */ + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x01 }, + { 0x0F,0x02,0x1F,0x05,0x3F,0x0A,0x7F,0x14,0x7E,0x28,0xFC,0x30,0xF8,0x40,0x60,0x00 }, + { 0x00,0x00,0x00,0x00,0x3C,0x00,0x7C,0x18,0xFC,0x28,0xFC,0x50,0xF8,0xA0,0xF0,0x40 }, + { 0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + /* Brush */ + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x01,0x0F,0x02 }, + { 0x1F,0x05,0x7F,0x0A,0xFF,0x34,0xFE,0x78,0xFC,0x78,0xFC,0x70,0xF8,0x40,0x60,0x00 }, + { 0x00,0x00,0x00,0x00,0x78,0x00,0xF8,0x30,0xF8,0x50,0xF8,0xA0,0xF0,0x40,0xE0,0x80 }, + { 0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + /* Fill */ + { 0x00,0x00,0x00,0x00,0x07,0x00,0x0F,0x02,0x1F,0x05,0x7F,0x08,0xFE,0x31,0xFD,0x63 }, + { 0xFA,0x77,0xFD,0x6E,0xFF,0x64,0xFF,0x62,0xF7,0x21,0x73,0x20,0x70,0x20,0x50,0x00 }, + { 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xC0,0x00,0xE0,0x80,0xF0,0xC0,0x78,0xA0 }, + { 0xF8,0x10,0xF8,0x20,0xF0,0x40,0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00 }, + /* Eraser */ + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0F,0x03 }, + { 0x1F,0x04,0x3F,0x08,0x7F,0x11,0xFF,0x22,0xFF,0x7D,0xFF,0x46,0xFF,0x7C,0x7E,0x00 }, + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xF0,0xE0 }, + { 0xF0,0x60,0xF0,0xA0,0xF0,0x40,0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00 }, + /* Cross */ + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x0E,0x04,0x0E,0x04 }, + { 0x0E,0x04,0xFF,0x04,0xFB,0x7B,0xFF,0x04,0x0E,0x04,0x0E,0x04,0x0E,0x04,0x0E,0x00 }, + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + { 0x00,0x00,0xE0,0x00,0xE0,0xC0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, +}; + +unsigned char data_buffer[NB_DATA_TILES][0x10]; + +const uint8_t colors[] = { WHITE, DKGREY, LTGREY, BLACK }; +const uint8_t modes[] = { SOLID, OR, XOR, AND }; + +uint8_t current_tool; +uint8_t current_color; +uint8_t current_mode; +uint8_t current_cursor; +uint8_t menu_cursor_pos; + +uint8_t cursor_x; +uint8_t cursor_y; + +void set_cursor() +{ + uint8_t x, y, i; + + i = 0; + for(x = 0; x < cursors[current_cursor].w; x++) + for(y = 0; y < cursors[current_cursor].h; y++) { + set_sprite_data(i, + 1, + cursors_data[cursors[current_cursor].data_idx+i]); + set_sprite_tile(i, i); + set_sprite_prop(i, 0x10); + i++; + } + /* Hide unused sprites */ + for(; i < 4; i++) { + move_sprite(i, 0, 0); + } +} + +void move_cursor() +{ + uint8_t x, y; + + for(x = 0; x < cursors[current_cursor].w; x++) + for(y = 0; y < cursors[current_cursor].h; y++) + move_sprite((x<<1)+y, + cursor_x+8 - cursors[current_cursor].hot_x + (x<<3), + cursor_y+16 - cursors[current_cursor].hot_y + (y<<3)); +} + +void move_menu_cursor() +{ + move_sprite(0, + ((icons[menu_cursor_pos].x+icons[menu_cursor_pos].w)<<3) + 4, + ((icons[menu_cursor_pos].y+icons[menu_cursor_pos].h)<<3) + 12); +} + +void set_icon(uint8_t icon, uint8_t selected) +{ + uint8_t x, y; + + for(x = 0; x < icons[icon].w; x++) + for(y = 0; y < icons[icon].h; y++) { + uint16_t index = icons[icon].data_idx+((uint16_t)x<<1)+y; + switch_data(icons[icon].x + x, + icons[icon].y + y, + selected ? selected_data[index] : data[index], + data_buffer[index]); + } +} + +void change_icon(uint8_t icon, uint8_t selected) +{ + uint8_t x, y; + + for(x = 0; x < icons[icon].w; x++) + for(y = 0; y < icons[icon].h; y++) + switch_data(icons[icon].x + x, + icons[icon].y + y, + (selected ? + selected_data[icons[icon].data_idx+((uint16_t)x<<1)+y] : + data[icons[icon].data_idx+((uint16_t)x<<1)+y]), + NULL); +} + +void reset_icon(uint8_t icon) +{ + uint8_t x, y; + + for(x = 0; x < icons[icon].w; x++) + for(y = 0; y < icons[icon].h; y++) + switch_data(icons[icon].x + x, + icons[icon].y + y, + data_buffer[icons[icon].data_idx+(x<<1)+y], + NULL); +} + +void splash() +{ + uint8_t x, y; + + cursor_x = 40; + cursor_y = 50; + current_cursor = PEN; + set_cursor(); + move_cursor(); + SHOW_SPRITES; + + for(; cursor_x < 120; cursor_x++) { + wait_vbl_done(); + move_cursor(); + plot(cursor_x, cursor_y, BLACK, SOLID); + } + for(; cursor_y < 94; cursor_y++) { + wait_vbl_done(); + move_cursor(); + plot(cursor_x, cursor_y, BLACK, SOLID); + } + for(; cursor_x > 40; cursor_x--) { + wait_vbl_done(); + move_cursor(); + plot(cursor_x, cursor_y, BLACK, SOLID); + } + for(; cursor_y > 50; cursor_y--) { + wait_vbl_done(); + move_cursor(); + plot(cursor_x, cursor_y, BLACK, SOLID); + } + cursor_x = 160/2; + cursor_y = 144/2; + current_cursor = FILL; + set_cursor(); + move_cursor(); + + for(y = 51; y < 94; y++) + for(x = 41; x < 120; x++) + plot(x, y, LTGREY, SOLID); + + // HIDE_SPRITES; +} + +void menu() +{ + uint8_t i, key; + uint8_t slowdown; + uint8_t cursor; + + slowdown = 50; + + for(i = 0; i < NB_TOOLS; i++) + set_icon(i, + i == FIRST_TOOL + current_tool || + i == FIRST_COLOR + current_color || + i == FIRST_MODE + current_mode); + + cursor = current_cursor; + current_cursor = ARROW; + set_cursor(); + move_menu_cursor(); + SHOW_SPRITES; + waitpadup(); + do { + wait_vbl_done(); + key = joypad(); + if(key & (J_UP|J_DOWN|J_LEFT|J_RIGHT)) { + if(key & J_UP) + menu_cursor_pos = icons[menu_cursor_pos].up; + if(key & J_DOWN) + menu_cursor_pos = icons[menu_cursor_pos].down; + if(key & J_LEFT) + menu_cursor_pos = icons[menu_cursor_pos].left; + if(key & J_RIGHT) + menu_cursor_pos = icons[menu_cursor_pos].right; + move_menu_cursor(); + while(slowdown && key == joypad()) { + wait_vbl_done(); + slowdown--; + } + slowdown = 10; + } else + slowdown = 50; + if(key & J_A) { + if( /* menu_cursor_pos >= FIRST_TOOL && */ menu_cursor_pos <= LAST_TOOL) { + if(menu_cursor_pos != /* FIRST_TOOL + */ current_tool) { + change_icon(/* FIRST_TOOL + */ current_tool, UNSELECTED); + current_tool = menu_cursor_pos /* - FIRST_TOOL */; + change_icon(/* FIRST_TOOL + */ current_tool, SELECTED); + cursor = icons[/* FIRST_TOOL + */ current_tool].cursor; + } + } else if(menu_cursor_pos >= FIRST_COLOR && menu_cursor_pos <= LAST_COLOR) { + if(menu_cursor_pos != FIRST_COLOR + current_color) { + change_icon(FIRST_COLOR + current_color, UNSELECTED); + current_color = menu_cursor_pos - FIRST_COLOR; + change_icon(FIRST_COLOR + current_color, SELECTED); + } + } else if(menu_cursor_pos >= FIRST_MODE && menu_cursor_pos <= LAST_MODE) { + if(menu_cursor_pos != FIRST_MODE + current_mode) { + change_icon(FIRST_MODE + current_mode, UNSELECTED); + current_mode = menu_cursor_pos - FIRST_MODE; + change_icon(FIRST_MODE + current_mode, SELECTED); + } + } + } + } while(key != J_SELECT); + waitpadup(); + for(i = 0; i < NB_TOOLS; i++) + reset_icon(i); + HIDE_SPRITES; + current_cursor = cursor; +} + +void run() +{ + uint8_t key; + uint8_t slowdown; + uint8_t drawn, erased; + + slowdown = 10; + drawn = erased = 0; + + set_cursor(); + move_cursor(); + SHOW_SPRITES; + + while(1) { + wait_vbl_done(); + key = joypad(); + if(key & (J_UP|J_DOWN|J_LEFT|J_RIGHT)) { + if(key & J_UP && cursor_y > 0) + cursor_y--; + if(key & J_DOWN && cursor_y < 143) + cursor_y++; + if(key & J_LEFT && cursor_x > 0) + cursor_x--; + if(key & J_RIGHT && cursor_x < 159) + cursor_x++; + move_cursor(); + while(slowdown && key == joypad()) { + wait_vbl_done(); + slowdown--; + } + slowdown = 1; + drawn = erased = 0; + } else + slowdown = 10; + if(key & J_SELECT) { + HIDE_SPRITES; + menu(); + set_cursor(); + move_cursor(); + SHOW_SPRITES; + } + if((key & (J_A|J_B)) == J_A) { + if(!drawn) { + drawn++; + plot(cursor_x, cursor_y, colors[current_color], modes[current_mode]); + } + } else + drawn = 0; + if((key & (J_A|J_B)) == J_B) { + if(!erased) { + erased++; + plot(cursor_x, cursor_y, WHITE, SOLID); + } + } else + erased = 0; + } +} + +void main() +{ + /* Initialize sprite palette */ + OBP1_REG = 0xE0U; + + splash(); + + current_tool = 0; + current_color = BLACK; + current_mode = SOLID; + current_cursor = PEN; + menu_cursor_pos = 0; + cursor_x = 160/2; + cursor_y = 144/2; + + run(); +} diff --git a/gbdk-lib/examples/ap/ram_function/Makefile b/gbdk-lib/examples/ap/ram_function/Makefile @@ -0,0 +1,32 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = ram_fn.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +%.o: %.c + $(CC) -c -o $@ $< + +%.s: %.c + $(CC) -S -o $@ $< + +%.o: %.s + $(CC) -c -o $@ $< + +%.pocket: %.o + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + + +ram_fn.o: ram_fn.c + $(CC) -D_inc_ram=0xD000 -D_inc_hiram=0xFFA0 -c -o $@ $< + +ram_fn.pocket: ram_fn.o + $(CC) -Wl-g_inc_ram=0xD000 -Wl-g_inc_hiram=0xFFA0 -o $@ $< + diff --git a/gbdk-lib/examples/ap/ram_function/ram_fn.c b/gbdk-lib/examples/ap/ram_function/ram_fn.c @@ -0,0 +1,71 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +uint16_t counter = 0; + +// inc() must be a relocatable function, be careful! +void inc() { + counter++; +} +// dummy function, needed to calculate inc() size, must be after it +void inc_end() {} + +// calculate the distance between objects +#define object_distance(a, b) ((void *)&(b) - (void *)&(a)) + +// variables at an absolute addresses which are defined by passing parameters to compiler +unsigned char __at _inc_ram ram_buffer[]; +unsigned char __at _inc_hiram hiram_buffer[]; + +// those are function pointer variables, we can initialize them right here +typedef void (*inc_t)(void); +inc_t inc_ram_var = (inc_t)ram_buffer; +inc_t inc_hiram_var = (inc_t)hiram_buffer; + +// those are defined by passing parameters to the linker, they must be located at the same +// addresses where ram_buffer and hiram_buffer are located +extern void inc_ram(); +extern void inc_hiram(); + +void print_counter() { + printf(" Counter is %u\n", counter); +} + +void main() { + // copy inc() function to it's new destinations: hiram_buffer and ram_buffer + hiramcpy((uint8_t)&hiram_buffer, (void *)&inc, (uint8_t)object_distance(inc, inc_end)); + memcpy(&ram_buffer, (void *)&inc, (uint16_t)object_distance(inc, inc_end)); + + // print initial counter state + puts("Program Start..."); + print_counter(); + + // Call function in ROM + puts("Call ROM"); + inc(); + print_counter(); + + // Call function in RAM using link-time address + puts("Call RAM direct"); + inc_ram(); + print_counter(); + + // Call function in RAM using pointer-to-function variable + puts("Call RAM indirect"); + inc_ram_var(); + print_counter(); + + // Call function in HIRAM using link-time address + puts("Call HIRAM direct"); + inc_hiram(); + print_counter(); + + // Call function in HIRAM using pointer-to-function variable + puts("Call HIRAM indirect"); + inc_hiram_var(); + print_counter(); + + puts("The End..."); +} diff --git a/gbdk-lib/examples/ap/rand/Makefile b/gbdk-lib/examples/ap/rand/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = rand.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/rand/rand.c b/gbdk-lib/examples/ap/rand/rand.c @@ -0,0 +1,59 @@ +/*************************************************************************** + * * + * Module : rand.c * + * * + * Purpose : A test for the rand() function, for the GBDK * + * * + * Version : 1, Januari 6 1998 * + * * + * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) * + * * + **************************************************************************/ + +#include <gb/gb.h> +#include <stdint.h> +#include <rand.h> +#include <gb/drawing.h> +#include <stdio.h> +#include <string.h> + +uint8_t accu[80]; +uint8_t accua[80]; + +void main(void) +{ + uint8_t r, s, t = 0, u = 0; + uint16_t seed; + + memset(accu, 0, sizeof(accu)); + memset(accua, 0, sizeof(accua)); + + /* We use the DIV register to get a random initial seed */ + puts("Getting seed"); + puts("Push any key (1)"); + waitpad(0xFF); + waitpadup(); + seed = DIV_REG; + puts("Push any key (2)"); + waitpad(0xFF); + waitpadup(); + seed |= (uint16_t)DIV_REG << 8; + + /* initarand() calls initrand() */ + initarand(seed); + + do { + r = rand(); + s = arand(); + + if(r < 80) { + t = ++accu[r]; + plot(r, 144-t, LTGREY, SOLID); + } + if(s < 80) { + u = ++accua[s]; + plot(s+80, 144-u, DKGREY, SOLID); + } + } + while(t != 144 && u != 144); +} diff --git a/gbdk-lib/examples/ap/rpn/Makefile b/gbdk-lib/examples/ap/rpn/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = rpn.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/rpn/rpn.c b/gbdk-lib/examples/ap/rpn/rpn.c @@ -0,0 +1,102 @@ +#include <stdint.h> +#include <stdio.h> +#include <ctype.h> + +#define MAXOP 40 +#define NUMBER '0' +#define STACKSIZE 40 + +uint8_t sp; +int16_t stack[STACKSIZE]; + +char s[MAXOP]; +uint8_t pos; +int16_t n; + +void push(int16_t l) +{ + if(sp < STACKSIZE) + stack[sp++] = l; + else + puts("Stack full"); +} + +int16_t pop(void) +{ + if(sp > 0) + return stack[--sp]; + else + puts("Stack empty"); + return 0; +} + +int16_t top(void) +{ + if(sp > 0) + return stack[sp-1]; + else + puts("Stack empty"); + return 0; +} + +int8_t read_op(void) +{ + if(pos == 0) { + gets(s); + } + + while(s[pos] == ' ' || s[pos] == '\t') + pos++; + + if(s[pos] == '\0') { + pos = 0; + return('\n'); + } + + if(!isdigit(s[pos])) + return(s[pos++]); + + n = s[pos] - '0'; + while(isdigit(s[++pos])) + n = 10 * n + s[pos] - '0'; + + return NUMBER; +} + +void main(void) +{ + int8_t type; + int16_t op2; + + puts("RPN Calculator"); + sp = 0; + pos = 0; + + while((type = read_op()) != 0) { + switch(type) { + case NUMBER: + push(n); + break; + case '+': + push(pop() + pop()); + break; + case '*': + push(pop() * pop()); + break; + case '-': + op2 = pop(); + push(pop() - op2); + break; + case '/': + op2 = pop(); + if(op2 != 0) + push(pop() / op2); + else + puts("Divide by 0"); + break; + case '\n': + printf("==> %d\n", top()); + break; + } + } +} diff --git a/gbdk-lib/examples/ap/samptest/Makefile b/gbdk-lib/examples/ap/samptest/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = samptest.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/samptest/samptest.c b/gbdk-lib/examples/ap/samptest/samptest.c @@ -0,0 +1,1639 @@ +/* + * Demonstration of sound sample player + * by Lars Malmborg <glue@df.lth.se> + */ + +#include <gb/gb.h> +#include <stdint.h> +#include <gb/sample.h> +#include <stdio.h> + +#define SAMPLES 25768 +extern const uint8_t sample[]; + +void main() +{ + puts("\n Ren & Stimpy\n"); + while(1) + { + waitpad(J_START); + puts("."); + play_sample(sample, SAMPLES / 32); + waitpadup(); + } +} + +const uint8_t sample[] = +{ +0x86,0x98,0x65,0x97,0x7b,0x79,0x66,0x77, +0x87,0x76,0x88,0x89,0x88,0x68,0x88,0x99, +0x66,0x78,0x88,0x69,0x79,0x87,0x78,0x86, +0x67,0x77,0x87,0x98,0x86,0x8a,0x7a,0x89, +0x76,0x75,0x96,0x64,0x76,0x67,0x6a,0x79, +0x8a,0xaa,0x88,0x68,0x69,0x55,0x6a,0xa7, +0x6b,0x98,0x92,0x78,0x66,0x88,0x68,0x97, +0xa4,0x58,0x96,0x9b,0xcb,0x79,0xba,0x11, +0x3a,0x00,0x8e,0xda,0xaf,0xb4,0x05,0x92, +0x07,0xe5,0x6b,0xfa,0x45,0xb7,0x08,0xb8, +0x77,0xd8,0x05,0xd2,0x27,0xee,0xa9,0xfc, +0x60,0x45,0x40,0x5d,0xca,0xad,0xb5,0x37, +0x97,0x46,0xa8,0x57,0xb6,0x26,0xc6,0x68, +0xed,0x67,0xd7,0x02,0x48,0x36,0xcf,0x9a, +0xb9,0x30,0x49,0x85,0xbb,0xc7,0x68,0x60, +0x38,0x98,0x7e,0xe9,0x88,0x40,0x54,0x7a, +0x7d,0xe8,0x85,0x43,0x66,0xa8,0xdc,0xa7, +0x52,0x66,0x67,0xbb,0xb8,0x79,0x84,0x56, +0x68,0x87,0x9a,0x97,0x77,0x35,0x86,0x9a, +0x8a,0x96,0x53,0x37,0x57,0xdb,0xa9,0xc9, +0x52,0x26,0x87,0x6d,0xc8,0x57,0x87,0x56, +0x58,0x97,0x9c,0xa8,0x65,0x32,0x6a,0xc9, +0x9a,0xa4,0x36,0xba,0x78,0xb6,0x05,0xbb, +0x99,0x99,0x62,0x39,0xc9,0x9a,0xa9,0x74, +0x03,0xaf,0x95,0x8a,0x60,0x3a,0xe9,0x88, +0xb8,0x10,0x7f,0xd6,0x59,0x95,0x15,0xcf, +0x85,0x8b,0x71,0x38,0xfc,0x65,0x98,0x44, +0x7d,0xc8,0x69,0x97,0x43,0x8d,0xb6,0x59, +0x88,0x44,0xbe,0x84,0x79,0x97,0x33,0x9d, +0x95,0x78,0x75,0x46,0xcd,0x84,0x7a,0x95, +0x34,0xbe,0x84,0x78,0x86,0x37,0xeb,0x64, +0x8a,0x94,0x18,0xeb,0x64,0x78,0x85,0x5c, +0xd8,0x46,0x9a,0x73,0x4b,0xe7,0x46,0x88, +0x65,0xae,0x95,0x58,0x97,0x33,0xae,0x95, +0x55,0x99,0x69,0xc9,0x56,0x78,0x85,0x36, +0xca,0x64,0x59,0xb6,0x59,0xa9,0x65,0x7a, +0x82,0x4b,0xb8,0x55,0x6a,0x74,0x9d,0x97, +0x58,0xa8,0x25,0x7e,0xb6,0x35,0xaa,0x77, +0x9a,0x86,0x78,0x85,0x36,0xcc,0x75,0x66, +0x98,0x7a,0xa8,0x67,0x89,0x72,0x4c,0xe7, +0x43,0x6a,0x96,0x89,0x77,0x77,0x77,0x44, +0xbd,0x86,0x66,0x89,0x69,0xb8,0x56,0x89, +0x95,0x35,0xdd,0x75,0x47,0xb9,0x79,0x87, +0x77,0x78,0x52,0x6d,0xc7,0x56,0x68,0x78, +0xda,0x75,0x68,0xa7,0x13,0xcf,0xa5,0x45, +0x9a,0x89,0x98,0x77,0x87,0x63,0x3b,0xea, +0x64,0x58,0x97,0x8b,0xa7,0x66,0x8a,0x63, +0x4c,0xda,0x63,0x5a,0xb9,0x98,0x78,0x77, +0x74,0x27,0xdc,0x85,0x34,0x99,0x9b,0x87, +0x76,0x79,0x71,0x2a,0xec,0x74,0x87,0xbb, +0xa7,0x68,0x89,0x74,0x22,0xbf,0xb7,0x34, +0x7a,0x9a,0x96,0x78,0x78,0x74,0x16,0xdb, +0x76,0x67,0x99,0x88,0x97,0x78,0x86,0x43, +0x8c,0x99,0x75,0x79,0x99,0x88,0x97,0x88, +0x75,0x37,0xbc,0xa6,0x57,0x9a,0x88,0x88, +0x97,0x75,0x45,0x99,0x98,0x77,0x78,0x79, +0x87,0xa9,0x77,0x41,0x4a,0xbb,0xb7,0x67, +0x66,0x99,0x79,0x89,0x75,0x33,0x7a,0xb8, +0x87,0x77,0x77,0x9a,0x98,0x78,0x51,0x49, +0xbb,0xa8,0x76,0x67,0x89,0xa9,0x77,0x84, +0x23,0x7a,0xca,0x98,0x66,0x58,0x9a,0x98, +0x76,0x52,0x27,0x9b,0xec,0x85,0x45,0x89, +0x89,0x98,0x87,0x53,0x47,0x9b,0xca,0x87, +0x66,0x78,0x8a,0xa9,0x94,0x23,0x79,0x9c, +0xcb,0x96,0x56,0x87,0x99,0x89,0x75,0x45, +0x78,0x9a,0xa9,0xa7,0x87,0x67,0x9a,0x75, +0x22,0x79,0xbb,0x89,0xa9,0x75,0x55,0x89, +0x9a,0x87,0x53,0x46,0x77,0xba,0xbb,0x77, +0x66,0x68,0x87,0x97,0x22,0x99,0x7a,0x7a, +0xd9,0x76,0x55,0x88,0x79,0x78,0x85,0x66, +0x65,0x79,0xab,0x98,0x98,0x69,0x88,0x71, +0x05,0x8a,0xd8,0x9a,0xbb,0x75,0x46,0x78, +0x98,0x97,0x46,0x75,0x77,0x89,0xa9,0x98, +0x77,0x88,0x8a,0x60,0x26,0x7d,0xa7,0x9b, +0xbb,0x84,0x47,0x89,0x98,0x85,0x46,0x77, +0x78,0x9b,0xa9,0x86,0x67,0x97,0x87,0x83, +0x16,0x69,0xa6,0x9b,0xcc,0x86,0x57,0x87, +0x65,0x65,0x57,0x89,0x76,0x8a,0x9b,0x87, +0x89,0x88,0x87,0x52,0x24,0x4a,0x78,0xbb, +0xcb,0x88,0x67,0x66,0x66,0x77,0x56,0x77, +0x86,0x79,0x8a,0xa8,0x98,0x89,0x86,0x87, +0x24,0x46,0x96,0x88,0xac,0xd8,0xa8,0x78, +0x85,0x55,0x68,0x89,0x87,0x87,0x87,0x87, +0x78,0x89,0x98,0x88,0x88,0x78,0x88,0x78, +0x87,0x88,0x87,0x78,0x87,0x87,0x78,0x88, +0x88,0x87,0x77,0x77,0x77,0x78,0x87,0x77, +0x76,0x77,0x77,0x78,0x78,0x87,0x88,0x89, +0x87,0x77,0x77,0x78,0x87,0x78,0x77,0x77, +0x77,0x78,0x88,0x77,0x88,0x77,0x88,0x78, +0x88,0x88,0x88,0x88,0x88,0x87,0x77,0x87, +0x78,0x88,0x87,0x88,0x88,0x78,0x88,0x77, +0x77,0x78,0x77,0x88,0x77,0x88,0x88,0x88, +0x89,0x77,0x77,0x78,0x87,0x68,0x77,0x87, +0x77,0x78,0x88,0x77,0x77,0x77,0x87,0x67, +0x78,0x88,0x88,0x88,0x88,0x88,0x88,0x87, +0x77,0x77,0x77,0x77,0x87,0x78,0x88,0x78, +0x77,0x87,0x77,0x77,0x78,0x88,0x87,0x78, +0x88,0x77,0x77,0x88,0x76,0x77,0x77,0x88, +0x77,0x77,0x88,0x87,0x78,0x88,0x87,0x78, +0x77,0x88,0x88,0x88,0x89,0x88,0x78,0x87, +0x87,0x68,0x88,0x87,0x87,0x88,0x77,0x77, +0x87,0x88,0x77,0x78,0x88,0x88,0x88,0x88, +0x88,0x77,0x77,0x78,0x76,0x67,0x77,0x77, +0x67,0x87,0x78,0x77,0x77,0x88,0x87,0x78, +0x77,0x77,0x87,0x88,0x88,0x78,0x87,0x88, +0x88,0x78,0x77,0x87,0x77,0x78,0x87,0x77, +0x77,0x88,0x78,0x88,0x88,0x88,0x78,0x89, +0x97,0x78,0x78,0x87,0x78,0x88,0x88,0x77, +0x87,0x78,0x88,0x77,0x77,0x88,0x78,0x89, +0x88,0x87,0x78,0x78,0x88,0x77,0x88,0x88, +0x77,0x88,0x87,0x87,0x77,0x88,0x87,0x87, +0x78,0x88,0x87,0x88,0x88,0x78,0x77,0x88, +0x87,0x77,0x77,0x87,0x77,0x77,0x88,0x87, +0x77,0x78,0x87,0x78,0x87,0x78,0x88,0x88, +0x88,0x88,0x88,0x88,0x98,0x78,0x78,0x77, +0x77,0x77,0x78,0x88,0x87,0x78,0x87,0x77, +0x77,0x88,0x77,0x87,0x78,0x88,0x88,0x78, +0x88,0x77,0x87,0x78,0x76,0x77,0x88,0x88, +0x87,0x88,0x87,0x78,0x78,0x88,0x87,0x77, +0x88,0x78,0x88,0x88,0x87,0x88,0x88,0x88, +0x88,0x76,0x78,0x87,0x77,0x78,0x87,0x78, +0x77,0x78,0x87,0x77,0x78,0x88,0x77,0x88, +0x88,0x78,0x77,0x77,0x78,0x77,0x77,0x77, +0x87,0x78,0x88,0x76,0x78,0x88,0x88,0x87, +0x87,0x78,0x77,0x88,0x88,0x87,0x78,0x98, +0x87,0x78,0x88,0x77,0x87,0x78,0x87,0x88, +0x77,0x88,0x87,0x77,0x88,0x77,0x77,0x77, +0x87,0x78,0x87,0x78,0x87,0x78,0x88,0x87, +0x78,0x87,0x78,0x77,0x78,0x77,0x88,0x87, +0x88,0x88,0x76,0x88,0x77,0x77,0x78,0x87, +0x88,0x88,0x88,0x88,0x76,0x78,0x77,0x78, +0x88,0x88,0x78,0x87,0x88,0x88,0x87,0x78, +0x87,0x78,0x77,0x88,0x87,0x78,0x77,0x77, +0x87,0x77,0x77,0x76,0x78,0x88,0x88,0x77, +0x87,0x88,0x77,0x77,0x77,0x76,0x78,0x88, +0x88,0x87,0x88,0x88,0x77,0x78,0x87,0x77, +0x78,0x87,0x88,0x88,0x88,0x88,0x88,0x78, +0x87,0x77,0x77,0x88,0x78,0x98,0x88,0x88, +0x78,0x77,0x88,0x76,0x78,0x88,0x88,0x88, +0x87,0x77,0x77,0x77,0x78,0x77,0x77,0x77, +0x78,0x78,0x88,0x78,0x87,0x77,0x77,0x87, +0x67,0x88,0x78,0x77,0x88,0x88,0x77,0x78, +0x87,0x67,0x77,0x78,0x88,0x78,0x88,0x88, +0x87,0x87,0x88,0x77,0x78,0x87,0x88,0x79, +0x87,0xa7,0x97,0x78,0x78,0x87,0x77,0x89, +0x79,0x67,0x89,0x88,0x79,0x78,0x77,0x88, +0x89,0x77,0x97,0x96,0x67,0x79,0x96,0x96, +0x78,0x88,0x68,0x89,0x68,0x66,0x77,0x97, +0xa6,0x67,0xa3,0xa4,0x68,0x39,0xa3,0x8b, +0x93,0xaa,0x87,0xb3,0xc9,0x56,0xa5,0x6a, +0x58,0x86,0x97,0x7b,0x76,0xc5,0x96,0x68, +0x98,0x74,0xcb,0x1a,0x68,0x97,0x66,0xa6, +0x87,0xa7,0x88,0x7d,0x79,0x7a,0x66,0x63, +0x46,0x78,0x98,0xa9,0xc7,0xa8,0xb7,0x49, +0x6a,0x86,0x77,0x86,0x44,0x88,0x57,0x88, +0x69,0x9b,0xfa,0xad,0xab,0x73,0x00,0x05, +0x45,0xbf,0xeb,0xb9,0x87,0x66,0x43,0x67, +0x69,0x99,0xb8,0x69,0x43,0x31,0x59,0xca, +0xdf,0xda,0x78,0x84,0x43,0x24,0x67,0x6d, +0xc9,0x9a,0x67,0x69,0xb7,0x58,0xb8,0x79, +0xb5,0x20,0x08,0xb3,0x8f,0xfa,0x48,0x96, +0x34,0x89,0x98,0x8a,0x50,0x59,0x93,0x7f, +0xf9,0x68,0xa7,0x37,0xb9,0x77,0x74,0x06, +0xa5,0x8c,0xec,0x66,0x98,0x45,0x88,0x88, +0x89,0x96,0x56,0x66,0x76,0x7b,0xa7,0x88, +0x99,0x76,0x79,0x77,0x95,0x61,0x4a,0xd8, +0x7b,0xc9,0x44,0x5a,0x78,0x8a,0x88,0x53, +0x6c,0x86,0x68,0x98,0x43,0x4a,0xea,0x78, +0xaa,0x65,0x77,0x88,0x79,0x87,0x31,0x7c, +0xba,0xaa,0x74,0x37,0xb9,0x88,0x99,0x74, +0x78,0x85,0x45,0xbb,0x74,0x9b,0x74,0x7c, +0xc7,0x47,0xa9,0x67,0x8b,0x70,0x18,0xdd, +0x67,0xba,0x53,0x59,0x97,0x78,0x98,0x43, +0xad,0xa9,0x66,0x86,0x44,0x6a,0xc9,0x78, +0x88,0x88,0x78,0x79,0x87,0x88,0x76,0x76, +0x44,0xb7,0xac,0xb5,0x55,0x78,0x89,0x97, +0x77,0x78,0x85,0x00,0x7e,0xe8,0x76,0x97, +0x45,0xab,0x86,0x58,0x9a,0x64,0x6a,0xaa, +0x87,0x47,0x79,0x8a,0x79,0x77,0x99,0x66, +0x77,0x88,0xa9,0x84,0x56,0x9b,0x35,0xdd, +0x75,0x59,0x96,0x6a,0x98,0x66,0x68,0x62, +0x6b,0xb8,0x68,0xab,0x55,0x9a,0x86,0x79, +0x88,0x98,0x55,0x26,0xd8,0x66,0xce,0x93, +0x35,0x8a,0xc8,0x76,0x79,0xa7,0x55,0x65, +0x66,0x6d,0xea,0x64,0x6a,0x97,0x56,0x88, +0x76,0x6a,0xb9,0x57,0xa7,0x54,0x4a,0xa8, +0x8a,0x99,0x65,0x98,0x68,0x88,0x86,0x57, +0x9b,0x94,0x66,0x67,0x28,0xfd,0x75,0x59, +0x77,0x9a,0x89,0x67,0x70,0x3c,0xe8,0x3b, +0xa9,0x16,0xca,0x57,0x8a,0x96,0x38,0xca, +0x75,0x68,0x56,0x5a,0xec,0x86,0x58,0x97, +0x79,0x77,0x77,0x98,0x12,0xde,0x46,0xac, +0x93,0x6b,0x85,0x57,0x99,0x64,0x6c,0xa8, +0x58,0x88,0x67,0x86,0x77,0x86,0x99,0xa8, +0x78,0x87,0x87,0x77,0x77,0x99,0x76,0x86, +0x76,0x46,0xda,0x98,0x87,0x66,0x8c,0xa8, +0x76,0x65,0x06,0xa6,0xbd,0xca,0x65,0x76, +0x47,0x99,0x76,0x6b,0x96,0x69,0x76,0x68, +0xa7,0x65,0x69,0x85,0xa9,0xa8,0x8a,0x76, +0x77,0x77,0x88,0x98,0x77,0x77,0x52,0x8d, +0xb8,0x8a,0x85,0x47,0x88,0x87,0x88,0x76, +0x56,0x95,0x5e,0xb9,0x97,0xa7,0x57,0x77, +0x88,0x77,0x79,0xa7,0x98,0x86,0x45,0x57, +0x6b,0x7b,0xb9,0xb7,0x77,0x66,0x76,0x66, +0x77,0x59,0x68,0x98,0x99,0x8a,0x78,0x88, +0x66,0x68,0x88,0x87,0x76,0x48,0x84,0xa9, +0x88,0x87,0x97,0x69,0x77,0x88,0x77,0x78, +0x89,0x79,0x88,0x76,0x87,0x77,0x78,0x87, +0x78,0x78,0x79,0x87,0x86,0x7a,0x68,0x77, +0x77,0x86,0x87,0x78,0x88,0x77,0x77,0x87, +0x88,0x79,0x88,0x97,0x87,0x77,0x77,0x67, +0x76,0x77,0x87,0x78,0x78,0x87,0x78,0x88, +0x89,0x98,0x88,0x89,0x87,0x77,0x77,0x77, +0x78,0x76,0x77,0x77,0x77,0x88,0x87,0x87, +0x88,0x78,0x88,0x88,0x88,0x88,0x88,0x87, +0x77,0x76,0x77,0x77,0x77,0x77,0x78,0x88, +0x88,0x88,0x88,0x87,0x87,0x77,0x77,0x88, +0x88,0x98,0x87,0x88,0x87,0x77,0x77,0x87, +0x77,0x87,0x88,0x88,0x77,0x77,0x87,0x77, +0x78,0x77,0x89,0x88,0x98,0x88,0x77,0x77, +0x77,0x76,0x67,0x67,0x87,0x78,0x88,0x87, +0x78,0x87,0x88,0x87,0x77,0x88,0x88,0x98, +0x98,0x87,0x87,0x77,0x77,0x76,0x78,0x77, +0x88,0x87,0x88,0x88,0x77,0x87,0x77,0x87, +0x87,0x78,0x88,0x88,0x88,0x87,0x88,0x77, +0x77,0x77,0x77,0x88,0x77,0x77,0x77,0x77, +0x78,0x88,0x88,0x87,0x78,0x87,0x88,0x78, +0x87,0x88,0x88,0x88,0x88,0x87,0x87,0x78, +0x87,0x77,0x88,0x87,0x78,0x88,0x77,0x87, +0x77,0x77,0x87,0x77,0x88,0x87,0x78,0x88, +0x78,0x87,0x77,0x78,0x77,0x67,0x87,0x78, +0x88,0x88,0x88,0x87,0x78,0x77,0x78,0x87, +0x87,0x88,0x88,0x88,0x88,0x87,0x87,0x77, +0x77,0x67,0x77,0x88,0x78,0x88,0x88,0x97, +0x78,0x78,0x87,0x77,0x89,0x88,0x78,0x87, +0x78,0x87,0x77,0x77,0x86,0x77,0x88,0x88, +0x88,0x87,0x88,0x87,0x88,0x77,0x88,0x88, +0x88,0x98,0x88,0x88,0x87,0x78,0x78,0x67, +0x77,0x77,0x77,0x98,0x78,0x88,0x78,0x87, +0x77,0x68,0x87,0x77,0x98,0x87,0x76,0x96, +0x87,0x87,0x87,0x79,0x68,0x77,0x87,0x87, +0x87,0x89,0x69,0x87,0x86,0x87,0x89,0x89, +0x79,0x98,0x76,0x88,0x69,0x86,0x77,0x87, +0x87,0x79,0x78,0x96,0x97,0x69,0x78,0x86, +0x78,0x59,0x98,0x78,0x88,0x86,0x88,0x68, +0x97,0x56,0x68,0x85,0x65,0xa6,0x46,0x7a, +0x75,0x79,0x76,0x67,0x98,0x97,0x99,0x6a, +0x6b,0x86,0xc5,0xa5,0xa7,0x57,0x78,0x4a, +0x48,0x56,0x8a,0x87,0x8a,0x78,0x88,0x78, +0xa8,0x4a,0x96,0x79,0x6a,0x87,0x67,0x86, +0x86,0x69,0x67,0xa8,0x88,0x89,0x7a,0x86, +0x85,0x88,0x74,0x45,0x87,0x38,0x67,0x86, +0xa7,0x9b,0xa8,0xba,0x78,0x89,0x55,0x96, +0x74,0x75,0x67,0x67,0x69,0x97,0x8d,0xa8, +0xa8,0xaa,0x59,0x69,0x44,0x77,0x84,0x66, +0x65,0x49,0x77,0x98,0xcb,0x7a,0xcb,0x58, +0x98,0x33,0x46,0x60,0x49,0xc5,0x9b,0xfc, +0x6d,0xd8,0x76,0x58,0x04,0x72,0x7a,0x16, +0xb8,0x58,0xba,0x87,0xde,0x9a,0xca,0x66, +0x68,0x41,0x11,0x95,0x06,0xea,0x7e,0xfc, +0x8a,0xa7,0x43,0x43,0x12,0x87,0x8a,0xca, +0x9c,0x67,0x65,0x43,0x67,0x8b,0xcc,0xb9, +0x99,0x46,0x85,0x65,0x5b,0x99,0x82,0x98, +0x36,0xa7,0xab,0xcb,0xb9,0xa7,0x44,0x67, +0x35,0x67,0x8b,0x58,0x89,0xa8,0x6b,0xb9, +0x78,0x78,0x64,0x55,0x77,0x67,0x79,0x76, +0x58,0xdb,0x8b,0xb9,0x47,0x66,0x47,0x99, +0x67,0xb9,0x76,0x13,0x67,0x6c,0xec,0xca, +0x89,0x63,0x43,0x44,0xcb,0x87,0xca,0x98, +0x75,0x05,0x34,0x6b,0xef,0xbb,0xc9,0x35, +0x12,0x49,0x6a,0xbb,0x98,0x89,0x20,0x06, +0x87,0xef,0xd9,0xa9,0x85,0x23,0x77,0x47, +0xec,0x89,0xa8,0x85,0x03,0x86,0x48,0xfd, +0x97,0xb9,0x52,0x36,0x67,0x7b,0xfa,0x88, +0x98,0x64,0x34,0x79,0x76,0x9d,0xc8,0x87, +0x97,0x34,0x9a,0x87,0x89,0x86,0x89,0x62, +0x68,0x44,0x9b,0xea,0x89,0xa5,0x34,0x76, +0x8b,0x98,0x78,0x74,0x79,0xb8,0x68,0x88, +0x45,0x53,0x5d,0xba,0x9b,0x97,0x45,0x87, +0x85,0x8b,0x98,0x77,0x65,0x56,0x85,0x19, +0xfc,0x68,0xca,0x63,0x6a,0x65,0x67,0xa8, +0x98,0x9a,0x56,0x36,0x51,0x7d,0xf9,0x8b, +0x97,0x34,0x78,0x78,0x89,0xa8,0x79,0x86, +0x56,0x48,0x85,0x7c,0xc8,0x8a,0x98,0x46, +0x76,0x68,0x88,0x99,0xa7,0x87,0x66,0x36, +0x86,0x37,0xda,0x79,0xa9,0x53,0x6b,0x77, +0x8a,0xa8,0x78,0x96,0x47,0x76,0x8a,0x63, +0x8a,0x93,0x7e,0xb4,0x7b,0x96,0x58,0x77, +0x58,0xb7,0x57,0x77,0x57,0x95,0x47,0xaa, +0x98,0x9a,0x66,0x88,0x87,0x88,0x76,0x6a, +0x66,0x5a,0x87,0x98,0x93,0x54,0x39,0x9a, +0xad,0xb9,0x77,0x74,0x37,0x96,0x7c,0xa9, +0x76,0x86,0x56,0x64,0x59,0x86,0x5c,0xb9, +0x89,0xb9,0x56,0x65,0x68,0x66,0x88,0x98, +0x88,0x87,0x57,0x65,0x66,0x97,0x6b,0xba, +0x9a,0x89,0x62,0x34,0x86,0xac,0xcc,0x88, +0x86,0x55,0x44,0x78,0x88,0xba,0x97,0x36, +0x44,0x58,0xad,0xeb,0xb9,0x99,0x45,0x33, +0x49,0x79,0xa9,0xc7,0x78,0x86,0x24,0x4b, +0x86,0xeb,0xc9,0x89,0x75,0x46,0x56,0x39, +0x98,0xaa,0xc8,0x57,0x65,0x67,0x9a,0xa6, +0xa9,0x65,0x09,0xc4,0x9b,0xaa,0x88,0xb7, +0x56,0x67,0x56,0x97,0x79,0x8a,0x96,0x87, +0x76,0x53,0x49,0x67,0xb9,0xca,0x8c,0x96, +0x76,0x57,0x68,0x95,0x99,0x89,0x88,0x76, +0x87,0x86,0x68,0x74,0x68,0x76,0x89,0xba, +0xaa,0x88,0x76,0x75,0x57,0x66,0x87,0x87, +0x78,0x77,0x98,0x77,0x78,0x97,0x88,0x78, +0x88,0x87,0x88,0x88,0x89,0x88,0x79,0x97, +0x77,0x67,0x87,0x77,0x77,0x88,0x87,0x87, +0x67,0x77,0x67,0x77,0x88,0x89,0x88,0x88, +0x88,0x88,0x88,0x88,0x98,0x77,0x77,0x76, +0x77,0x78,0x77,0x77,0x77,0x79,0x88,0x77, +0x98,0x88,0x78,0x88,0x87,0x77,0x77,0x77, +0x88,0x77,0x78,0x77,0x76,0x78,0x88,0x77, +0x88,0x88,0x78,0x78,0x77,0x88,0x77,0x78, +0x88,0x76,0x78,0x77,0x87,0x88,0x87,0x88, +0x88,0x78,0x89,0x87,0x88,0x88,0x88,0x78, +0x88,0x87,0x88,0x87,0x78,0x77,0x77,0x88, +0x87,0x88,0x88,0x87,0x87,0x87,0x77,0x66, +0x77,0x78,0x87,0x78,0x78,0x87,0x78,0x88, +0x87,0x77,0x77,0x77,0x87,0x77,0x88,0x77, +0x87,0x88,0x88,0x78,0x87,0x78,0x88,0x87, +0x78,0x87,0x78,0x88,0x98,0x77,0x77,0x77, +0x77,0x88,0x78,0x88,0x78,0x88,0x88,0x77, +0x77,0x77,0x78,0x88,0x87,0x88,0x78,0x88, +0x87,0x77,0x77,0x77,0x77,0x78,0x88,0x77, +0x88,0x78,0x88,0x77,0x77,0x88,0x78,0x88, +0x98,0x98,0x88,0x88,0x87,0x87,0x77,0x77, +0x77,0x77,0x78,0x88,0x87,0x88,0x87,0x78, +0x87,0x87,0x77,0x78,0x77,0x88,0x88,0x78, +0x87,0x77,0x87,0x78,0x77,0x77,0x87,0x88, +0x88,0x78,0x87,0x77,0x77,0x87,0x77,0x78, +0x88,0x88,0x88,0x88,0x88,0x87,0x77,0x88, +0x77,0x77,0x78,0x77,0x77,0x88,0x88,0x88, +0x77,0x87,0x87,0x77,0x88,0x77,0x87,0x78, +0x87,0x78,0x77,0x78,0x77,0x87,0x88,0x87, +0x77,0x88,0x88,0x88,0x87,0x88,0x87,0x78, +0x87,0x87,0x77,0x88,0x88,0x87,0x78,0x87, +0x78,0x77,0x87,0x77,0x77,0x78,0x87,0x88, +0x88,0x98,0x77,0x77,0x78,0x87,0x88,0x78, +0x77,0x77,0x77,0x88,0x87,0x67,0x78,0x78, +0x77,0x77,0x77,0x78,0x88,0x88,0x98,0x77, +0x78,0x88,0x88,0x88,0x77,0x88,0x78,0x87, +0x87,0x77,0x78,0x78,0x77,0x88,0x77,0x78, +0x88,0x98,0x88,0x77,0x77,0x77,0x77,0x78, +0x87,0x77,0x78,0x88,0x87,0x88,0x77,0x77, +0x77,0x77,0x78,0x77,0x88,0x88,0x97,0x78, +0x87,0x88,0x87,0x88,0x78,0x87,0x78,0x88, +0x88,0x77,0x87,0x77,0x77,0x88,0x78,0x78, +0x88,0x88,0x98,0x78,0x77,0x77,0x67,0x77, +0x78,0x77,0x88,0x77,0x87,0x78,0x87,0x77, +0x77,0x77,0x78,0x77,0x88,0x88,0x88,0x88, +0x77,0x87,0x77,0x88,0x88,0x88,0x88,0x78, +0x87,0x78,0x77,0x77,0x77,0x77,0x88,0x78, +0x89,0x88,0x87,0x88,0x77,0x77,0x77,0x77, +0x87,0x78,0x88,0x78,0x77,0x87,0x77,0x77, +0x77,0x77,0x88,0x78,0x88,0x78,0x88,0x78, +0x88,0x87,0x78,0x78,0x88,0x88,0x88,0x78, +0x78,0x77,0x77,0x77,0x77,0x78,0x87,0x78, +0x87,0x88,0x88,0x88,0x77,0x87,0x77,0x78, +0x78,0x77,0x87,0x77,0x78,0x78,0x87,0x88, +0x77,0x78,0x78,0x87,0x88,0x87,0x88,0x78, +0x88,0x87,0x87,0x89,0x88,0x88,0x87,0x87, +0x88,0x77,0x88,0x77,0x77,0x88,0x78,0x87, +0x77,0x87,0x87,0x87,0x77,0x77,0x76,0x88, +0x77,0x87,0x78,0x77,0x87,0x77,0x77,0x78, +0x77,0x88,0x87,0x87,0x78,0x88,0x88,0x87, +0x87,0x78,0x78,0x88,0x87,0x88,0x88,0x88, +0x78,0x76,0x77,0x77,0x78,0x88,0x77,0x87, +0x88,0x88,0x88,0x87,0x77,0x77,0x77,0x88, +0x77,0x77,0x88,0x88,0x88,0x77,0x77,0x77, +0x78,0x88,0x78,0x88,0x88,0x88,0x89,0x77, +0x87,0x87,0x78,0x88,0x78,0x88,0x88,0x88, +0x88,0x77,0x77,0x77,0x78,0x87,0x78,0x78, +0x88,0x88,0x88,0x77,0x77,0x77,0x77,0x77, +0x77,0x78,0x88,0x88,0x88,0x87,0x77,0x77, +0x78,0x77,0x77,0x78,0x88,0x88,0x88,0x77, +0x78,0x77,0x78,0x87,0x77,0x78,0x98,0x88, +0x88,0x87,0x78,0x87,0x88,0x77,0x77,0x78, +0x98,0x88,0x88,0x87,0x78,0x87,0x87,0x77, +0x77,0x78,0x87,0x88,0x87,0x77,0x78,0x77, +0x88,0x87,0x77,0x78,0x87,0x88,0x87,0x87, +0x88,0x77,0x88,0x87,0x77,0x88,0x88,0x88, +0x87,0x87,0x78,0x77,0x88,0x87,0x77,0x88, +0x88,0x87,0x77,0x87,0x78,0x87,0x87,0x87, +0x77,0x78,0x88,0x77,0x77,0x77,0x77,0x77, +0x78,0x87,0x78,0x88,0x87,0x77,0x77,0x78, +0x78,0x87,0x88,0x88,0x88,0x88,0x88,0x78, +0x77,0x87,0x78,0x87,0x78,0x88,0x88,0x88, +0x87,0x78,0x77,0x88,0x78,0x87,0x78,0x88, +0x78,0x88,0x77,0x67,0x77,0x87,0x78,0x87, +0x88,0x88,0x87,0x88,0x77,0x77,0x67,0x87, +0x78,0x77,0x89,0x87,0x88,0x88,0x77,0x78, +0x77,0x87,0x87,0x77,0x88,0x87,0x87,0x87, +0x77,0x77,0x78,0x87,0x87,0x77,0x88,0x77, +0x76,0x87,0x77,0x77,0x78,0x76,0x88,0x87, +0x88,0x77,0x77,0x88,0x87,0x78,0x87,0x78, +0x87,0x88,0x88,0x87,0x77,0x87,0x88,0x78, +0x88,0x78,0x87,0x87,0x78,0x77,0x77,0x87, +0x87,0x78,0x88,0x78,0x88,0x87,0x78,0x88, +0x67,0x77,0x87,0x78,0x88,0x78,0x87,0x87, +0x68,0x88,0x78,0x77,0x87,0x78,0x88,0x78, +0x87,0x77,0x68,0x88,0x88,0x77,0x88,0x78, +0x97,0x88,0x77,0x77,0x77,0x88,0x78,0x77, +0x88,0x77,0x98,0x78,0x77,0x77,0x77,0x88, +0x77,0x77,0x87,0x78,0x77,0x86,0x77,0x87, +0x78,0x78,0x86,0x78,0x88,0x78,0x77,0x87, +0x88,0x88,0x78,0x87,0x87,0x78,0x98,0x78, +0x77,0x77,0x78,0x88,0x88,0x78,0x77,0x88, +0x88,0x88,0x78,0x87,0x88,0x78,0x88,0x88, +0x86,0x78,0x77,0x78,0x77,0x77,0x78,0x78, +0x88,0x78,0x87,0x77,0x77,0x88,0x88,0x77, +0x87,0x78,0x88,0x88,0x77,0x77,0x78,0x88, +0x88,0x77,0x88,0x78,0x88,0x88,0x66,0x77, +0x77,0x88,0x88,0x78,0x88,0x87,0x87,0x88, +0x66,0x77,0x77,0x88,0x88,0x77,0x88,0x87, +0x87,0x87,0x76,0x78,0x87,0x77,0x88,0x88, +0x88,0x88,0x77,0x87,0x87,0x77,0x88,0x77, +0x88,0x88,0x78,0x88,0x76,0x77,0x77,0x77, +0x88,0x87,0x78,0x98,0x87,0x78,0x77,0x67, +0x77,0x87,0x68,0x88,0x67,0x88,0x88,0x67, +0x87,0x77,0x88,0x78,0x77,0x88,0x76,0x88, +0x88,0x77,0x88,0x77,0x78,0x89,0x87,0x88, +0x77,0x78,0x88,0x87,0x78,0x87,0x77,0x98, +0x87,0x77,0x77,0x77,0x88,0x78,0x78,0x88, +0x77,0x89,0x77,0x76,0x77,0x77,0x89,0x88, +0x87,0x88,0x77,0x79,0x87,0x76,0x78,0x87, +0x89,0x88,0x88,0x78,0x87,0x78,0x77,0x77, +0x68,0x87,0x88,0x88,0x88,0x78,0x87,0x77, +0x78,0x77,0x77,0x98,0x78,0x89,0x88,0x87, +0x87,0x77,0x77,0x87,0x77,0x88,0x77,0x87, +0x98,0x78,0x77,0x77,0x77,0x78,0x78,0x77, +0x88,0x77,0x89,0x88,0x78,0x77,0x77,0x78, +0x87,0x78,0x77,0x87,0x88,0x97,0x77,0x87, +0x78,0x78,0x88,0x77,0x87,0x78,0x77,0x88, +0x76,0x78,0x88,0x77,0x88,0x86,0x88,0x77, +0x87,0x87,0x87,0x78,0x88,0x87,0x88,0x88, +0x78,0x87,0x78,0x77,0x78,0x77,0x88,0x87, +0x77,0x88,0x87,0x78,0x77,0x87,0x78,0x88, +0x78,0x87,0x87,0x78,0x87,0x78,0x87,0x77, +0x77,0x78,0x77,0x77,0x77,0x68,0x88,0x77, +0x88,0x77,0x77,0x78,0x88,0x88,0x78,0x88, +0x88,0x88,0x88,0x87,0x77,0x78,0x87,0x88, +0x77,0x78,0x88,0x88,0x88,0x77,0x77,0x88, +0x88,0x87,0x87,0x88,0x88,0x88,0x87,0x87, +0x77,0x78,0x87,0x88,0x78,0x78,0x88,0x87, +0x88,0x78,0x77,0x87,0x77,0x78,0x88,0x88, +0x88,0x88,0x88,0x77,0x87,0x77,0x78,0x78, +0x78,0x88,0x88,0x88,0x78,0x87,0x77,0x78, +0x78,0x77,0x88,0x78,0x88,0x88,0x87,0x77, +0x67,0x77,0x77,0x77,0x77,0x87,0x98,0x88, +0x87,0x77,0x76,0x87,0x78,0x77,0x77,0x78, +0x88,0x88,0x88,0x77,0x77,0x77,0x77,0x78, +0x78,0x77,0x88,0x88,0x88,0x87,0x77,0x87, +0x77,0x88,0x77,0x77,0x88,0x88,0x88,0x88, +0x77,0x77,0x77,0x78,0x78,0x88,0x88,0x78, +0x89,0x77,0x88,0x88,0x77,0x78,0x66,0x88, +0x79,0x77,0x88,0x77,0x88,0x99,0x66,0x88, +0x77,0x86,0x89,0x67,0x98,0x67,0x87,0x89, +0x67,0x88,0x77,0x87,0x79,0x77,0x88,0x77, +0x88,0x89,0x77,0x87,0x66,0x77,0x79,0x76, +0x87,0x77,0x88,0x89,0x67,0x88,0x67,0x87, +0x78,0x77,0x97,0x78,0x77,0x99,0x78,0x98, +0x67,0x78,0x88,0x68,0x87,0x68,0x88,0x8a, +0x77,0x88,0x77,0x78,0x88,0x77,0x87,0x68, +0x97,0x89,0x87,0x97,0x78,0x76,0x88,0x67, +0x87,0x67,0x88,0x78,0x77,0x87,0x57,0x87, +0x79,0x77,0x98,0x67,0x87,0x79,0x76,0x98, +0x68,0x97,0x79,0x87,0x98,0x57,0x97,0x79, +0x76,0x88,0x58,0x97,0x79,0x87,0x98,0x67, +0xa8,0x79,0x87,0x88,0x67,0x86,0x7a,0x76, +0x98,0x57,0x97,0x79,0x77,0x88,0x59,0x96, +0x79,0x76,0x87,0x68,0x97,0x89,0x77,0x96, +0x58,0x96,0x79,0x77,0x97,0x68,0x86,0x78, +0x77,0x97,0x69,0x96,0x79,0x89,0xa8,0x6a, +0x97,0x99,0x77,0x87,0x59,0x86,0x79,0x88, +0x87,0x58,0x87,0x88,0x78,0x88,0x69,0x65, +0x78,0x68,0xa6,0x79,0x76,0x88,0x79,0x99, +0x89,0x86,0x88,0x67,0x87,0x68,0x87,0x78, +0x88,0x87,0x78,0x76,0x89,0x88,0x98,0x88, +0x66,0x77,0x78,0x87,0x89,0x76,0x77,0x88, +0x88,0x89,0x87,0x87,0x77,0x78,0x79,0x97, +0x78,0x88,0x87,0x78,0x87,0x88,0x88,0x88, +0x77,0x66,0x66,0x78,0x87,0x78,0x87,0x66, +0x88,0x89,0x89,0x98,0x88,0x76,0x57,0x67, +0x89,0x87,0x89,0x88,0x77,0x99,0x77,0x88, +0x88,0x87,0x77,0x66,0x77,0x99,0x67,0x88, +0x66,0x78,0x88,0x88,0x88,0x88,0x86,0x78, +0x66,0x7a,0x86,0x88,0x97,0x77,0x99,0x88, +0xa8,0x79,0x97,0x66,0x76,0x67,0x88,0x76, +0x79,0x76,0x78,0x88,0x89,0x78,0x87,0x66, +0x56,0x76,0x78,0x98,0x77,0x88,0x88,0x78, +0x88,0x99,0x78,0x98,0x77,0x78,0x77,0x78, +0x97,0x68,0x87,0x77,0x87,0x98,0x78,0x88, +0x88,0x66,0x88,0x67,0x87,0x67,0x77,0x87, +0x67,0x99,0x89,0x76,0x98,0x76,0x77,0x77, +0x76,0x98,0x67,0x88,0x88,0x77,0x99,0x98, +0x78,0x77,0x55,0x78,0x78,0x89,0x88,0x77, +0x97,0x78,0x98,0x9a,0x87,0x88,0x87,0x77, +0x88,0x76,0x88,0x77,0x88,0x88,0x77,0x87, +0x89,0x78,0x88,0x76,0x76,0x78,0x77,0x97, +0x68,0x86,0x78,0x88,0x99,0x87,0x77,0x78, +0x76,0x98,0x67,0x77,0x77,0x79,0x76,0x77, +0x77,0x9a,0x77,0x87,0x77,0x76,0x77,0x78, +0x86,0x68,0x87,0x78,0x78,0x98,0x88,0x77, +0x88,0x88,0x88,0x88,0x77,0x78,0x88,0xa7, +0x89,0x98,0x89,0x87,0x87,0x88,0x66,0x77, +0x67,0x87,0x67,0x88,0x77,0x89,0x99,0x88, +0x87,0x78,0x77,0x88,0x77,0x87,0x77,0x88, +0x88,0x77,0x99,0x88,0x66,0x67,0x75,0x77, +0x78,0x76,0x77,0x87,0x78,0x87,0x88,0x78, +0x87,0x77,0x88,0x98,0x78,0x97,0x77,0x78, +0x99,0x77,0x88,0x87,0x88,0x88,0x67,0x87, +0x76,0x77,0x77,0x66,0x77,0x97,0x78,0x9a, +0x87,0x88,0x87,0x78,0x99,0x98,0x87,0x88, +0x77,0x9a,0x98,0x87,0x87,0x67,0x87,0x78, +0x66,0x87,0x65,0x67,0x77,0x76,0x87,0x76, +0x78,0x88,0x86,0x79,0x87,0x89,0x99,0x86, +0x68,0x77,0x88,0x98,0x98,0x78,0x87,0x67, +0x88,0x86,0x57,0x76,0x67,0x88,0x89,0x87, +0x88,0x77,0x9a,0x97,0x78,0x88,0x88,0x99, +0x88,0x77,0x78,0x89,0x88,0x86,0x67,0x77, +0x77,0x77,0x88,0x76,0x66,0x66,0x67,0x88, +0x87,0x76,0x67,0x88,0x88,0x88,0x77,0x88, +0x87,0x88,0x86,0x78,0x89,0x99,0x99,0x88, +0x87,0x67,0x66,0x78,0x98,0x88,0x87,0x77, +0x87,0x87,0x87,0x67,0x89,0x88,0x98,0x98, +0x89,0x78,0x87,0x88,0x88,0x98,0x77,0x74, +0x66,0x77,0x97,0x98,0x98,0x97,0x88,0x76, +0x77,0x66,0x65,0x46,0x52,0x47,0x76,0x8a, +0xba,0xcc,0xa9,0x78,0x76,0x57,0x85,0x46, +0x64,0x56,0x78,0xbc,0x9b,0xcb,0x88,0x78, +0x56,0x77,0x67,0x75,0x25,0x86,0x47,0xcd, +0x7b,0xde,0x9a,0xb9,0x57,0x86,0x58,0x99, +0x32,0x77,0x44,0x9c,0xb8,0xde,0xb7,0xbb, +0x62,0x68,0x73,0x67,0x33,0x44,0x33,0x8a, +0xa6,0xbe,0xc8,0x9a,0xa5,0x68,0x83,0x55, +0x44,0x85,0x55,0xa9,0xca,0xca,0xca,0xa8, +0x95,0x55,0x64,0x74,0x15,0x54,0x38,0x9a, +0xac,0xde,0xab,0x99,0x67,0x77,0x67,0x85, +0x14,0x45,0x39,0xac,0xbf,0xfc,0x9a,0xb7, +0x58,0x85,0x22,0x21,0x63,0x25,0x9b,0x99, +0xdd,0xb9,0x99,0x77,0x66,0x55,0x74,0x06, +0x37,0x29,0x8c,0xbe,0xcd,0xad,0xb8,0x57, +0x66,0x55,0x52,0x52,0x43,0x89,0xa9,0xed, +0xdb,0xb9,0x97,0x65,0x56,0x53,0x33,0x67, +0x59,0xaa,0x9a,0xdc,0xac,0xb8,0x98,0x87, +0x55,0x33,0x28,0x34,0x47,0x9b,0xae,0xc8, +0xcc,0x76,0x55,0x64,0x36,0x42,0x37,0x55, +0x77,0xaa,0x9d,0xda,0xba,0xa7,0x65,0x76, +0x55,0x41,0x86,0x84,0x99,0x88,0xab,0xba, +0xb9,0x98,0x76,0x64,0x68,0x64,0x88,0x56, +0x89,0x99,0x9c,0xb9,0x99,0x88,0x78,0x76, +0x89,0x87,0x48,0x88,0x98,0x99,0x56,0x77, +0x77,0x78,0x88,0x66,0x66,0x66,0x87,0x78, +0x67,0x76,0x77,0x66,0x89,0xa8,0x78,0x88, +0x78,0x9a,0x88,0x98,0x78,0x88,0x77,0x76, +0x55,0x67,0x89,0x78,0x88,0x78,0x88,0x78, +0x88,0x98,0x88,0x88,0x78,0x87,0x78,0x88, +0x77,0x77,0x89,0x77,0x88,0x88,0x98,0x89, +0x87,0x87,0x77,0x77,0x77,0x76,0x65,0x77, +0x66,0x56,0x66,0x78,0x89,0x77,0x98,0x89, +0x99,0x78,0x76,0x78,0x88,0x88,0x87,0x79, +0x87,0x78,0x77,0x88,0x87,0x67,0x77,0x78, +0x88,0x78,0x87,0x77,0x99,0x99,0x87,0x77, +0x78,0x88,0x88,0x86,0x78,0x87,0x79,0x88, +0x99,0x98,0x88,0x77,0x77,0x76,0x77,0x66, +0x67,0x87,0x65,0x86,0x56,0x77,0x68,0x96, +0x78,0x98,0x87,0x77,0x66,0x78,0x98,0x89, +0x77,0x98,0x88,0x89,0x87,0x78,0x86,0x78, +0x68,0x88,0x98,0x88,0x88,0x78,0x87,0x87, +0x87,0x77,0x79,0x99,0x98,0x87,0x68,0x97, +0x88,0x88,0x99,0x98,0x88,0x77,0x66,0x66, +0x67,0x78,0x77,0x87,0x76,0x77,0x66,0x76, +0x88,0x77,0x77,0x89,0x86,0x57,0x86,0x68, +0x79,0x88,0x66,0x68,0x89,0x99,0xa9,0x87, +0x78,0x77,0x89,0x89,0xa8,0x67,0x88,0x78, +0x89,0x96,0x59,0x66,0x89,0xaa,0x89,0x76, +0x77,0x87,0x88,0x88,0x68,0x98,0x87,0x98, +0x86,0x67,0x66,0x88,0x87,0x98,0x76,0x65, +0x67,0x78,0x87,0x88,0x66,0x77,0x77,0x78, +0x78,0x76,0x76,0x67,0x88,0x79,0xa9,0x88, +0x88,0x88,0x88,0x97,0x66,0x77,0x89,0x88, +0x79,0x97,0x78,0x75,0x78,0x78,0x98,0x89, +0x96,0x78,0x98,0x97,0x66,0x78,0x88,0xa9, +0x88,0x76,0x77,0x78,0x88,0x78,0x76,0x77, +0x76,0x68,0x77,0x77,0x56,0x77,0x68,0x88, +0x79,0x75,0x68,0x88,0x75,0x67,0x87,0x78, +0x8a,0xa8,0x79,0xa8,0x88,0x98,0x78,0x77, +0x99,0x87,0x79,0x99,0x87,0x77,0x67,0x89, +0x89,0xa9,0x78,0x77,0x88,0x77,0x78,0x89, +0x98,0x78,0x87,0x77,0x76,0x89,0x77,0x75, +0x67,0x76,0x68,0x67,0x77,0x77,0x58,0x57, +0x86,0x66,0x88,0x76,0x67,0x96,0x55,0x66, +0x89,0x87,0x89,0x88,0x88,0x99,0x99,0x99, +0x75,0x78,0x88,0x98,0x8a,0xa7,0x76,0x77, +0x77,0x88,0xa9,0x78,0x87,0x78,0x97,0x87, +0x68,0x98,0x88,0x89,0x99,0x76,0x68,0x89, +0x98,0x66,0x76,0x76,0x67,0x98,0x97,0x75, +0x67,0x76,0x67,0x78,0x87,0x68,0x77,0x66, +0x75,0x57,0x88,0x97,0x66,0x99,0x88,0x88, +0x99,0x97,0x67,0x76,0x98,0x89,0x89,0x98, +0x76,0x78,0x78,0x79,0x89,0x97,0x89,0x89, +0x99,0x77,0x87,0x58,0x97,0x66,0x77,0x76, +0x78,0x9a,0x97,0x76,0x67,0x75,0x88,0x88, +0x98,0x76,0x76,0x67,0x68,0x88,0x87,0x78, +0x56,0x78,0x66,0x66,0x78,0x77,0x76,0x99, +0x88,0x98,0x88,0x89,0x87,0x78,0x98,0x88, +0x98,0xa8,0x76,0x88,0x77,0x88,0x97,0xa9, +0x99,0x77,0x98,0x88,0x86,0x7a,0x87,0x75, +0x68,0x88,0x78,0x97,0x77,0x67,0x86,0x77, +0x87,0x77,0x87,0x87,0x56,0x77,0x66,0x76, +0x89,0x76,0x56,0x68,0x65,0x68,0x77,0x89, +0x76,0x68,0x69,0x98,0x99,0x98,0x67,0x77, +0xa7,0x79,0x89,0x87,0x87,0x8a,0x88,0xb8, +0x77,0x7a,0x8a,0x78,0x99,0x86,0x67,0x78, +0xa8,0x87,0x69,0x69,0x78,0xa9,0x99,0x77, +0x57,0x87,0x88,0x89,0x87,0x65,0x54,0x67, +0x85,0x67,0x69,0x87,0x67,0x78,0x77,0xa5, +0x54,0x67,0x85,0x57,0xbb,0x76,0xac,0xb8, +0x88,0xaa,0x62,0x55,0x76,0x34,0x9d,0x97, +0x9b,0xe9,0x88,0xbc,0xa5,0x02,0x98,0x58, +0x68,0xba,0x57,0xa8,0x53,0x58,0xdc,0x57, +0xec,0x83,0x7a,0xb7,0x30,0x15,0x62,0x4d, +0xee,0xbb,0xeb,0x54,0x55,0x10,0x05,0x89, +0x59,0xfb,0x9b,0x84,0x33,0x05,0xa6,0x8e, +0xed,0xc8,0x77,0x62,0x39,0x85,0x59,0xdc, +0xc8,0x3b,0x64,0x87,0x6c,0xea,0xbb,0x79, +0xa4,0x23,0x52,0x44,0xde,0xbc,0xd9,0x96, +0x10,0x58,0x55,0xad,0xdc,0x8a,0xb9,0x40, +0x02,0x31,0x38,0xde,0xfb,0xac,0xa4,0x35, +0x53,0x54,0x56,0x98,0x9a,0x96,0x78,0x63, +0x58,0x99,0x9c,0xea,0x78,0xa9,0x43,0x57, +0x70,0x1a,0xf7,0x56,0xcf,0xb5,0x8c,0x94, +0x36,0x76,0x78,0xa9,0x57,0xa9,0x54,0x79, +0x65,0x9c,0xca,0x8a,0xb8,0x55,0x79,0x78, +0x96,0x52,0x6a,0x65,0x6b,0xf9,0x57,0xa9, +0x44,0x66,0x76,0x69,0x85,0x79,0x8a,0x96, +0x77,0x65,0x64,0x57,0x8a,0xdb,0xaa,0xa8, +0x86,0x54,0x44,0x79,0xa9,0xac,0x98,0x79, +0x87,0x23,0x35,0x9b,0xcd,0xc9,0x88,0x87, +0x66,0x55,0x68,0x77,0x74,0x9b,0x85,0x6d, +0xc9,0x79,0xa8,0x56,0x78,0x54,0x88,0x87, +0x78,0x87,0x64,0x47,0x95,0x6e,0xd6,0x7a, +0xa8,0x75,0x76,0x34,0x87,0x57,0x85,0x2a, +0xa6,0xaa,0xdc,0x75,0x8a,0x66,0x77,0x86, +0x79,0xa8,0x89,0x89,0x95,0x68,0x88,0x64, +0x59,0x86,0x79,0xa9,0x87,0x9b,0x75,0x89, +0x77,0x65,0x88,0x99,0x77,0x67,0x76,0x63, +0x75,0x59,0x9c,0xa9,0xaa,0x96,0x45,0x76, +0x56,0x77,0x99,0x96,0x67,0x85,0x45,0x57, +0x99,0x9c,0xb7,0xa9,0x56,0x56,0x77,0x8b, +0xa8,0x98,0x57,0x75,0x35,0x9b,0xae,0xdb, +0xa8,0x87,0x55,0x56,0x89,0x78,0x88,0x87, +0x66,0x86,0x96,0x58,0x89,0x42,0x6c,0x79, +0xbc,0xc7,0x66,0x65,0x64,0x48,0x7c,0x87, +0x5b,0x77,0x77,0x46,0x48,0x65,0x4b,0xb7, +0x9b,0xb9,0x88,0xb6,0x54,0x83,0x37,0x98, +0xaa,0xaa,0x99,0x04,0x41,0x7b,0xab,0xfe, +0xb7,0x9a,0x85,0x57,0x65,0x67,0x98,0xca, +0x86,0x7a,0x64,0x47,0x94,0x6b,0xd9,0x99, +0xa7,0x57,0x76,0x67,0x66,0x45,0x86,0x67, +0xb9,0x86,0x98,0x65,0x4c,0x87,0x8a,0xb7, +0x98,0x85,0x59,0x76,0x69,0x95,0x67,0x99, +0x65,0x3a,0xa8,0x87,0xba,0x76,0x99,0x77, +0x6a,0x6a,0xa6,0x87,0x78,0x56,0x50,0x7c, +0x88,0xcc,0xa9,0x86,0xa5,0x56,0x86,0x79, +0x7b,0xa7,0x49,0x83,0x66,0x75,0x3a,0xb8, +0x89,0xca,0x48,0x95,0x78,0x85,0x77,0x86, +0x42,0x58,0x97,0x6e,0xd8,0x9a,0x77,0x86, +0x55,0x86,0x86,0xa7,0x77,0x89,0x67,0x98, +0x76,0x96,0x55,0xaf,0x88,0xcf,0xa5,0x77, +0x44,0x66,0x66,0x78,0x78,0x57,0x87,0xa8, +0xbb,0xba,0xaa,0x74,0x48,0x66,0x68,0x75, +0x78,0x62,0x27,0xa4,0x1d,0xf5,0xbf,0x97, +0x86,0x76,0x36,0x54,0x35,0x9a,0x9b,0xaa, +0x87,0x94,0x36,0x45,0x89,0xbb,0xcb,0xa9, +0x76,0x76,0x26,0x76,0xa8,0xa7,0x9b,0x55, +0x88,0xa5,0x8a,0x96,0x76,0x67,0x89,0xa9, +0x89,0x97,0x32,0x48,0xb1,0x5f,0xb6,0xcd, +0x66,0x84,0x47,0x53,0x57,0x9a,0x98,0xac, +0x97,0x86,0x43,0x41,0x29,0xd5,0xae,0xb9, +0xaa,0x97,0x65,0x75,0x47,0x88,0x98,0x9b, +0x98,0x65,0x43,0x25,0x78,0xcc,0xbb,0xaa, +0x99,0x86,0x55,0x22,0x33,0x8a,0x69,0xdc, +0x99,0xb8,0x78,0x87,0x67,0x88,0x78,0x97, +0x98,0x66,0x48,0x85,0x89,0x99,0x88,0x88, +0x79,0x86,0x97,0x67,0x12,0x98,0x38,0xf9, +0x5b,0xb7,0x88,0x77,0x66,0x76,0x77,0x98, +0x54,0x9b,0x79,0xba,0x79,0x95,0x76,0x89, +0x87,0x88,0x68,0x76,0x87,0x54,0x9a,0x8a, +0xbb,0x77,0x87,0x65,0x87,0x76,0x78,0x54, +0x9a,0x58,0xd9,0x9a,0xa7,0x75,0x25,0x64, +0x67,0x99,0x87,0xab,0x93,0x25,0x52,0x7d, +0xb9,0xec,0x76,0x88,0x62,0x14,0x76,0x8b, +0xcc,0xaa,0x77,0x82,0x55,0x68,0xea,0xbc, +0x88,0x98,0x75,0x45,0x55,0x57,0xa9,0x89, +0xbb,0x78,0x98,0x46,0x87,0x67,0xa9,0x65, +0x29,0xd3,0x3c,0xf8,0x9c,0xa7,0x78,0x75, +0x33,0x43,0x6a,0xc9,0xbc,0x88,0x65,0x77, +0x13,0x6b,0x77,0xbe,0x97,0x89,0x54,0x57, +0x64,0x47,0x76,0x7c,0xe8,0x9d,0x76,0x66, +0x67,0x55,0x87,0x79,0x67,0xab,0x76,0x87, +0x74,0x59,0x76,0x9c,0xa8,0x99,0x97,0x57, +0x76,0x58,0x60,0x7f,0x96,0xcc,0x9a,0x98, +0x97,0x56,0x75,0x56,0x75,0x58,0x88,0x65, +0xed,0x98,0xb7,0x46,0x76,0x66,0x58,0x84, +0x68,0x46,0xb7,0x4a,0xca,0xab,0x89,0x97, +0x69,0x84,0x68,0x74,0x21,0x8b,0x54,0xef, +0x98,0xba,0x84,0x66,0x63,0x56,0x66,0x9a, +0x98,0xb7,0x87,0x68,0x75,0x3b,0xc9,0x7c, +0xc7,0x68,0x77,0x55,0x54,0x56,0x8a,0xaa, +0x8a,0x76,0x77,0x67,0x78,0x88,0x77,0x88, +0x77,0x75,0x34,0x66,0x79,0xba,0xcb,0xa8, +0x87,0x86,0x66,0x86,0x76,0x79,0xa8,0x89, +0x86,0x97,0x77,0x56,0x9d,0x87,0x9a,0x77, +0x79,0x76,0x66,0x87,0x78,0x97,0x88,0xa9, +0x88,0x88,0x76,0x88,0x76,0x87,0x67,0x76, +0x88,0x88,0x9a,0x87,0x77,0x56,0x64,0x87, +0x98,0x78,0x86,0x77,0x86,0x57,0x86,0x68, +0x8c,0x97,0xa9,0x56,0x87,0x77,0x76,0x76, +0x9b,0x67,0x99,0x88,0x88,0x68,0x78,0x97, +0x79,0x89,0x89,0x37,0x57,0x78,0x89,0x77, +0x88,0xa9,0x88,0x99,0x66,0x8a,0x68,0x77, +0x67,0x78,0x77,0x98,0x98,0x98,0x95,0x87, +0x78,0x57,0x78,0x87,0x67,0x84,0x77,0x98, +0x66,0x98,0xa9,0x78,0x8b,0x66,0x88,0x85, +0x67,0x88,0x87,0x88,0x85,0x88,0x98,0x78, +0x88,0x97,0x67,0x78,0x88,0x67,0x57,0x69, +0xa9,0x77,0x88,0x99,0x88,0x79,0x79,0x77, +0x86,0x65,0x66,0x77,0x88,0x88,0x68,0x97, +0x77,0x76,0x87,0x57,0x79,0x77,0x78,0x66, +0x68,0x87,0x76,0x88,0x89,0x96,0x78,0x88, +0x89,0x87,0x87,0x88,0x78,0x89,0x97,0x77, +0x69,0x97,0x77,0x98,0x79,0x78,0x77,0x87, +0x67,0x79,0x98,0x86,0x78,0x99,0x97,0x69, +0x88,0x77,0x77,0x67,0x56,0x66,0x99,0x97, +0x77,0x77,0x77,0x76,0x87,0x68,0x98,0x87, +0x88,0x65,0x56,0x97,0x78,0x78,0x79,0x97, +0x69,0x88,0x88,0x77,0x87,0x87,0x77,0x89, +0x86,0x76,0x78,0x97,0x88,0x99,0x89,0x87, +0x78,0x78,0x77,0x78,0x78,0x77,0x77,0x88, +0x96,0x78,0x99,0x88,0x86,0x76,0x67,0x77, +0x88,0xa9,0x88,0x77,0x78,0x66,0x77,0x89, +0x88,0x77,0x96,0x66,0x57,0x78,0x87,0x87, +0x78,0x86,0x69,0x97,0x88,0x78,0x87,0x77, +0x77,0x87,0x98,0x77,0x67,0x88,0x87,0x88, +0x98,0x98,0x77,0x87,0x87,0x87,0x68,0x88, +0x87,0x88,0x86,0x69,0xa8,0x88,0x86,0x66, +0x77,0x87,0x88,0x98,0x88,0x66,0x88,0x65, +0x78,0x88,0x99,0x87,0x87,0x76,0x67,0x77, +0x78,0x97,0x88,0x87,0x88,0x88,0x99,0x98, +0x78,0x78,0x77,0x88,0x87,0x78,0x68,0x79, +0x77,0x88,0x78,0x87,0x88,0x79,0x89,0x66, +0x77,0x88,0x97,0x79,0x67,0x68,0x87,0x88, +0x87,0x67,0x67,0x67,0x88,0x88,0x87,0x66, +0x77,0x46,0x78,0x88,0x88,0x88,0x77,0x77, +0x77,0x77,0x68,0x78,0x78,0x89,0x87,0x88, +0x89,0x98,0x79,0x77,0x66,0x88,0x78,0x78, +0x76,0x79,0x87,0x68,0x87,0x88,0x67,0x89, +0x89,0x66,0x78,0x87,0x88,0x78,0x8a,0x97, +0x88,0x87,0x77,0x79,0x87,0x77,0x89,0x89, +0x77,0x76,0x65,0x76,0x78,0x88,0x98,0x76, +0x77,0x88,0x86,0x86,0x97,0x77,0x77,0xa9, +0x87,0x79,0x7a,0x78,0x79,0x77,0x77,0x86, +0x78,0x67,0x57,0x87,0x84,0x58,0x97,0x86, +0x78,0xa7,0x77,0x78,0x68,0x96,0x96,0x78, +0x8b,0x87,0x86,0x98,0x87,0x87,0x76,0xa6, +0xa8,0x8a,0x78,0x68,0x58,0x96,0x79,0xa5, +0x95,0x87,0x77,0x97,0x79,0x58,0x77,0x87, +0x77,0x98,0x87,0xa8,0xb9,0x88,0x67,0x77, +0x86,0x8a,0x78,0x67,0x78,0x68,0x85,0x68, +0x78,0x59,0x47,0x86,0x88,0x6a,0x68,0x95, +0x95,0x79,0x7a,0x58,0x68,0x97,0x8a,0x87, +0x68,0x89,0x99,0x86,0x67,0x63,0x98,0x55, +0x77,0xa8,0x76,0x79,0x7b,0x97,0xb7,0xc5, +0x77,0x46,0x47,0x86,0x85,0xc8,0xac,0x5a, +0x99,0x97,0x8a,0xb8,0x58,0x64,0x93,0x77, +0x66,0x57,0x89,0xa6,0xab,0x8a,0x59,0xa9, +0x76,0x74,0x28,0x56,0x78,0x67,0x79,0x9a, +0xb9,0x99,0xba,0x99,0xa7,0xb2,0x03,0x66, +0x74,0x45,0xba,0xa6,0x8c,0xa9,0x97,0xca, +0xa6,0x45,0x60,0x43,0x73,0x35,0xaa,0xac, +0xae,0xed,0xb6,0x9b,0x6b,0x62,0x41,0x35, +0x27,0x23,0xa8,0x9b,0xaf,0xdc,0x88,0xc9, +0x86,0x72,0x00,0x66,0x31,0x29,0xdd,0xaa, +0xdf,0xdc,0x88,0x98,0x73,0x34,0x33,0x14, +0x88,0x58,0xcf,0xfb,0x8a,0xca,0x75,0x57, +0x97,0x30,0x07,0xa7,0x43,0xbf,0xe8,0x8c, +0xda,0x86,0x87,0x64,0x44,0x21,0x69,0x96, +0x5a,0xfe,0x98,0xac,0xa6,0x45,0x76,0x66, +0x62,0x16,0xca,0x51,0x9f,0xe9,0x79,0xba, +0x74,0x37,0x88,0x64,0x25,0xba,0x52,0x5e, +0xfa,0x56,0xcc,0x95,0x56,0x86,0x44,0x78, +0x77,0x77,0xa9,0x76,0x7a,0xa7,0x67,0x9a, +0x87,0x89,0x98,0x86,0x33,0x7a,0x95,0x29, +0xed,0x97,0x8a,0xb8,0x54,0x77,0x75,0x46, +0x99,0x76,0x89,0x98,0x78,0x98,0x88,0x78, +0x87,0x87,0x88,0x74,0x04,0xcb,0x61,0x8f, +0xda,0x57,0xc9,0x75,0x47,0x67,0x65,0xaa, +0x87,0x78,0x78,0x96,0x66,0x78,0x88,0x89, +0xa9,0x77,0x79,0x98,0x41,0x5c,0xa5,0x19, +0xfd,0x64,0x8b,0x88,0x44,0x88,0x75,0x69, +0x86,0x57,0xb8,0x48,0xba,0x75,0x89,0x97, +0x77,0x89,0x88,0x73,0x49,0x96,0x34,0xdc, +0x97,0x9c,0x97,0x65,0x87,0x55,0x58,0xa9, +0x64,0x9c,0x85,0x48,0xb9,0x76,0x9a,0x76, +0x78,0x98,0x86,0x68,0x5c,0x94,0x37,0xfa, +0x78,0xbd,0x86,0x67,0x74,0x46,0x68,0x86, +0x57,0xb9,0x76,0x7b,0xa6,0x5a,0xb7,0x56, +0x88,0x76,0x79,0x61,0x6c,0x63,0x39,0xd7, +0x89,0xdb,0x78,0x88,0x74,0x54,0x67,0x56, +0x69,0xb8,0x87,0xbb,0x67,0x8a,0x88,0x97, +0x76,0x58,0x98,0x51,0x6f,0x81,0x4d,0xf5, +0x5c,0xe9,0x5a,0xb8,0x64,0x67,0x55,0x67, +0x77,0x78,0xa7,0x69,0xb9,0x58,0xa8,0x88, +0x88,0x66,0x77,0x73,0x3a,0xb3,0x29,0xe8, +0x38,0xda,0x57,0xca,0x66,0x77,0x44,0x57, +0x65,0x78,0xa8,0x89,0xaa,0x86,0x9a,0x86, +0x8b,0x85,0x68,0x76,0x41,0x7d,0x41,0x7c, +0xe6,0x4e,0xf7,0x3b,0xc7,0x59,0x95,0x35, +0x67,0x66,0x79,0xa9,0x76,0x9a,0x66,0xaa, +0x77,0xa9,0x77,0x77,0x57,0x63,0x6b,0x63, +0x7d,0xb4,0x8e,0xc6,0x6b,0xa5,0x59,0x85, +0x56,0x66,0x56,0x79,0x98,0x8a,0xa9,0x78, +0xa8,0x78,0x99,0x77,0x77,0x55,0x23,0xc7, +0x07,0xfa,0x39,0xfa,0x68,0xb9,0x56,0x98, +0x54,0x67,0x76,0x66,0x79,0xa8,0x67,0xaa, +0x77,0xba,0x76,0x99,0x65,0x78,0x55,0x63, +0x5a,0x54,0xbc,0x76,0xcc,0x87,0x89,0x75, +0x68,0x85,0x56,0x76,0x54,0x6b,0xb6,0x7a, +0xb9,0x68,0xca,0x68,0xb9,0x55,0x97,0x45, +0x52,0x9b,0x38,0xdd,0x78,0xfd,0x77,0x89, +0x76,0x67,0x85,0x47,0x98,0x55,0x8c,0xa5, +0x7a,0x86,0x78,0x99,0x97,0x78,0x86,0x78, +0x65,0x50,0x4d,0x61,0x9d,0x96,0xae,0xa7, +0x78,0x85,0x45,0x76,0x44,0x6a,0x74,0x4b, +0xd8,0x58,0xba,0x65,0x79,0xa8,0x68,0x99, +0x56,0x98,0x50,0x0b,0xd3,0x28,0xed,0x68, +0xdd,0x95,0x8a,0x75,0x46,0x65,0x78,0x89, +0x77,0xab,0x75,0x98,0x78,0x88,0x9a,0x95, +0x7a,0x95,0x58,0x76,0x11,0xbd,0x53,0x8d, +0xc9,0x89,0xaa,0x65,0x67,0x73,0x36,0x87, +0x79,0xb9,0x87,0x69,0x85,0x37,0xbb,0x98, +0xab,0xa7,0x56,0x76,0x54,0x47,0x63,0x6b, +0xb8,0x89,0xdc,0x98,0x88,0x85,0x43,0x67, +0x66,0x88,0x8c,0xd9,0x54,0x8a,0x64,0x37, +0xbb,0xa8,0x8c,0xb6,0x44,0x77,0x77,0x54, +0x22,0xcf,0x52,0xaf,0xe8,0x59,0x98,0x74, +0x45,0x78,0x65,0x7b,0xcb,0x87,0x57,0x87, +0x65,0x5b,0xea,0x67,0xa9,0x65,0x55,0x79, +0x97,0x62,0x4c,0xd6,0x46,0xce,0xc8,0x56, +0x99,0x75,0x45,0x88,0x78,0x9b,0xba,0x73, +0x48,0x86,0x55,0x9b,0xca,0x97,0x78,0x86, +0x56,0x89,0x86,0x42,0x3a,0xd9,0x65,0x9d, +0xb8,0x65,0x57,0x76,0x44,0x58,0xa9,0x89, +0xb9,0x65,0x56,0x77,0x67,0x8a,0xba,0x88, +0x87,0x78,0x79,0x99,0x87,0x41,0x5c,0xda, +0x65,0x8c,0xdb,0x84,0x58,0x76,0x54,0x79, +0x9a,0xa9,0x99,0x65,0x46,0x78,0x68,0x8a, +0x99,0x89,0x98,0x87,0x77,0x77,0x87,0x52, +0x49,0xba,0x85,0x69,0xbb,0x96,0x45,0x67, +0x78,0x76,0x68,0xaa,0xa8,0x42,0x47,0x99, +0x75,0x6a,0xba,0x98,0x99,0x98,0x77,0x77, +0x65,0x33,0x5a,0xca,0x77,0x9c,0xd9,0x65, +0x66,0x66,0x77,0x67,0x89,0xaa,0x97,0x54, +0x47,0x98,0x77,0x7a,0xbb,0xa9,0x87,0x87, +0x77,0x77,0x76,0x42,0x58,0x9a,0x86,0x78, +0x9a,0xa9,0x86,0x77,0x78,0x87,0x77,0x88, +0x86,0x22,0x48,0xaa,0x86,0x8a,0xcc,0xb9, +0x87,0x87,0x98,0x76,0x64,0x22,0x7b,0xda, +0x75,0x7a,0xbb,0xa8,0x76,0x67,0x87,0x55, +0x77,0x9a,0x84,0x24,0x8a,0xa9,0x78,0xab, +0xa9,0x98,0x66,0x77,0x77,0x56,0x98,0x42, +0x48,0xcb,0x74,0x69,0xdc,0x96,0x67,0x77, +0x67,0x75,0x57,0x99,0x72,0x14,0xad,0xa8, +0x8a,0xdc,0x99,0x98,0x65,0x79,0x98,0x73, +0x02,0x5b,0xea,0x76,0x79,0xdd,0xb8,0x66, +0x56,0x77,0x77,0x78,0x75,0x44,0x69,0xba, +0x99,0x9b,0xb9,0x87,0x76,0x66,0x67,0x87, +0x75,0x43,0x49,0xcb,0x84,0x48,0xdf,0xa5, +0x55,0x78,0x75,0x56,0x56,0x78,0x64,0x34, +0x98,0xc9,0x9a,0xbb,0xa8,0x77,0x76,0x89, +0x96,0x00,0x28,0xee,0x97,0x8a,0xba,0x88, +0x86,0x65,0x57,0x76,0x79,0x86,0x22,0x7c, +0xd9,0x79,0xbb,0xa7,0x79,0x86,0x57,0x97, +0x66,0x53,0x38,0xcc,0x95,0x6c,0xeb,0x64, +0x46,0x76,0x67,0x78,0x89,0xa6,0x00,0x7d, +0xb7,0x46,0xde,0xb6,0x68,0x98,0x77,0x87, +0x66,0x64,0x23,0x8e,0xfa,0x99,0xba,0x65, +0x67,0x78,0xab,0xa6,0x00,0x39,0xdb,0x88, +0xbc,0xa7,0x56,0x54,0x46,0x89,0x89,0xa8, +0x42,0x5b,0xb8,0x7a,0xcb,0x74,0x57,0x66, +0x78,0x77,0x8a,0x73,0x15,0xbb,0x88,0x99, +0xba,0x85,0x25,0x87,0x76,0x79,0x87,0x9b, +0x62,0x49,0xac,0xcd,0xb7,0x56,0x76,0x68, +0xbc,0xa9,0x30,0x17,0xdb,0x77,0xee,0x84, +0x44,0x57,0x88,0x66,0xab,0x98,0x52,0x03, +0x9d,0xcb,0xbb,0x86,0x77,0x66,0x78,0x89, +0x99,0x20,0x4e,0xc6,0x36,0xde,0x96,0x44, +0x79,0x65,0x79,0x98,0x78,0x84,0x22,0x7c, +0xaa,0xcc,0x97,0x66,0x55,0x89,0x9a,0xa5, +0x03,0xac,0x86,0x8c,0xd9,0x44,0x68,0x86, +0x67,0xab,0x78,0x83,0x04,0xaa,0x69,0xfc, +0x65,0x67,0x79,0xa8,0x79,0x84,0x26,0xc9, +0x66,0xae,0xb5,0x56,0x79,0x75,0x68,0x99, +0x89,0x72,0x27,0x96,0x7b,0xb9,0x76,0x78, +0x77,0x88,0x98,0x62,0x17,0xea,0x34,0xcf, +0xa4,0x67,0x99,0x66,0x79,0x98,0x86,0x23, +0xba,0x56,0xce,0x95,0x67,0x88,0x77,0x89, +0x96,0x01,0xad,0x62,0x6e,0xf7,0x48,0x98, +0x75,0x58,0xa8,0x68,0x98,0x55,0x79,0x67, +0x89,0xa9,0x89,0x87,0x67,0x88,0x75,0x14, +0xcc,0x43,0xae,0xc5,0x59,0x97,0x66,0x8a, +0x95,0x6a,0x95,0x48,0xa8,0x78,0xaa,0x87, +0x88,0x76,0x89,0x87,0x52,0x5c,0x94,0x7c, +0xc8,0x68,0x87,0x64,0x68,0x97,0x68,0xba, +0x55,0x7a,0x84,0x4b,0xc7,0x5a,0xa8,0x68, +0x88,0x77,0x50,0x4e,0xc1,0x5d,0xc5,0x4b, +0xa5,0x58,0x87,0x77,0x87,0xa8,0x47,0x88, +0x55,0x9b,0x87,0x8a,0x97,0x88,0x88,0x76, +0x34,0xda,0x17,0xec,0x46,0xc9,0x46,0x77, +0x67,0x88,0x99,0x87,0x77,0x75,0x57,0xa8, +0x6a,0xb9,0x98,0x98,0x78,0x63,0x28,0xb4, +0x3b,0xf9,0x4b,0xc6,0x58,0x85,0x67,0x78, +0x66,0x89,0x86,0x79,0x87,0x66,0x99,0x88, +0x88,0x56,0x88,0x62,0x5c,0x63,0x6e,0xb4, +0x9d,0x85,0x7a,0x74,0x67,0x88,0x77,0x87, +0x89,0x66,0x8a,0x75,0x9b,0x87,0x98,0x66, +0x98,0x74,0x28,0xa5,0x4b,0xe8,0x5d,0xc6, +0x69,0x84,0x48,0x76,0x77,0x57,0xb6,0x5b, +0xa6,0x78,0x86,0x8a,0x87,0x9a,0x88,0x48, +0x94,0x49,0xa8,0x6b,0xb6,0x8b,0x86,0x67, +0x65,0x87,0x99,0x77,0x89,0x75,0x99,0x47, +0xb9,0x69,0xb8,0x68,0x88,0x53,0x6c,0x52, +0x8d,0x54,0xec,0x57,0xb8,0x67,0x87,0x46, +0x88,0x65,0x99,0x75,0x8b,0x64,0xba,0x58, +0xa8,0x79,0x97,0x66,0x62,0x69,0x35,0xd9, +0x7b,0xb9,0x88,0x97,0x67,0x75,0x58,0x87, +0x78,0x88,0x97,0x89,0x98,0x78,0x98,0x9a, +0x77,0x97,0x67,0x76,0x58,0x75,0x79,0x79, +0xa9,0xa9,0x68,0x76,0x86,0x66,0x78,0x78, +0x89,0x87,0x77,0x79,0x87,0x88,0x79,0x77, +0x86,0x88,0x77,0x98,0x77,0x66,0x87,0x66, +0x89,0x78,0x89,0x89,0x97,0x78,0x76,0x87, +0x66,0x87,0x78,0x86,0x77,0x99,0x98,0x88, +0x87,0x79,0x87,0x89,0x77,0x77,0x86,0x77, +0x76,0x78,0x99,0x87,0x78,0x77,0x98,0x77, +0x87,0x67,0x88,0x99,0x67,0x86,0x77,0x87, +0x89,0x76,0x78,0x87,0x88,0x88,0x88,0x78, +0x76,0x77,0x78,0x87,0x7a,0x98,0x76,0x67, +0x77,0x77,0x87,0x69,0x89,0x98,0x78,0x99, +0x87,0x89,0x88,0x78,0x88,0x75,0x67,0x89, +0x88,0x77,0x76,0x78,0x98,0x77,0x88,0x87, +0x77,0x78,0x87,0x77,0x78,0x77,0x77,0x77, +0x88,0x87,0x78,0x87,0x78,0x77,0x89,0x87, +0x78,0x88,0x87,0x56,0x88,0x78,0x89,0x99, +0x77,0x77,0x77,0x87,0x77,0x88,0x89,0x76, +0x78,0x9a,0x87,0x89,0x97,0x77,0x98,0x86, +0x77,0x88,0x87,0x89,0x76,0x78,0x98,0x66, +0x78,0x87,0x77,0x78,0x77,0x68,0x99,0x78, +0x98,0x67,0x79,0x98,0x77,0x87,0x76,0x77, +0x88,0x86,0x78,0x87,0x77,0x66,0x77,0x88, +0x88,0x88,0x77,0x87,0x67,0x77,0x67,0x88, +0x9a,0x87,0x87,0x89,0x87,0x78,0x98,0x87, +0x77,0x77,0x77,0x88,0x88,0x88,0x76,0x67, +0x98,0x66,0x77,0x77,0x77,0x89,0x77,0x88, +0x88,0x88,0x88,0x76,0x79,0x98,0x77,0x78, +0x98,0x89,0x88,0x66,0x78,0x98,0x87,0x76, +0x67,0x89,0x89,0x99,0x87,0x66,0x68,0x77, +0x76,0x78,0x98,0x77,0x87,0x99,0x99,0x87, +0x78,0x87,0x79,0x77,0x77,0x78,0x89,0x89, +0x87,0x78,0x88,0x66,0x77,0x98,0x67,0x87, +0x67,0x76,0x89,0x79,0x98,0x76,0x78,0x89, +0x86,0x68,0x87,0x68,0x78,0x87,0x68,0x87, +0x78,0x87,0x77,0x89,0x88,0x87,0x87,0x76, +0x78,0x87,0x66,0x78,0x89,0x98,0x88,0x88, +0x8a,0x88,0x78,0x88,0x77,0x78,0x77,0x68, +0x89,0x88,0x87,0x87,0x78,0x76,0x77,0x88, +0x77,0x88,0x77,0x76,0x78,0x89,0x88,0x77, +0x98,0x98,0x77,0x68,0x98,0x78,0x87,0x75, +0x67,0x88,0x88,0x78,0x67,0x89,0x98,0x77, +0x87,0x56,0x87,0x76,0x86,0x78,0x87,0x98, +0x89,0x89,0x99,0x87,0x78,0x98,0x78,0x86, +0x87,0x77,0x8b,0x79,0x99,0x66,0x66,0x86, +0x78,0x97,0x76,0x87,0x98,0x78,0x5a,0x97, +0x99,0x87,0x99,0x78,0xa7,0x46,0xa6,0x68, +0x78,0x76,0x76,0x79,0x99,0x99,0x77,0x9a, +0x77,0x96,0x76,0x87,0x56,0x78,0x65,0x77, +0x99,0xb8,0x88,0x9a,0xa9,0xa9,0x76,0x65, +0x75,0x78,0x87,0x57,0x79,0x6b,0x9c,0x79, +0x88,0x89,0x85,0x78,0x95,0x35,0x86,0x84, +0x54,0xa9,0xb9,0x9a,0xbb,0x88,0x9c,0x95, +0x35,0x78,0x74,0x44,0x78,0x84,0x79,0xec, +0x99,0xbb,0xaa,0x67,0x88,0x64,0x12,0x06, +0x86,0x41,0x7e,0xfc,0xaa,0xfd,0xa3,0x47, +0x99,0x21,0x48,0x71,0x56,0xb7,0x87,0xbf, +0xfa,0x98,0x99,0x54,0x37,0x76,0x42,0x04, +0x7d,0x76,0x8c,0xfa,0x87,0x9d,0x77,0x18, +0x76,0x65,0x60,0x68,0xa8,0x78,0xbe,0xa8, +0x87,0x87,0x85,0x56,0x77,0x89,0x77,0x66, +0x68,0x86,0x77,0x8a,0x99,0x88,0x9a,0x87, +0x78,0x98,0x61,0x03,0xac,0xb8,0x9d,0xeb, +0x74,0x58,0x95,0x44,0x38,0xb9,0x67,0xbc, +0xba,0x74,0x34,0x77,0x76,0x9e,0xdb,0x67, +0x98,0x77,0x53,0x57,0x76,0x69,0xab,0xbc, +0xa7,0x77,0x54,0x58,0x79,0xa8,0x79,0xa8, +0x40,0x27,0x99,0x89,0xbc,0xb8,0x56,0x89, +0x64,0x35,0x7a,0x99,0xaa,0xb9,0x76,0x42, +0x25,0x88,0x9b,0xdd,0xc9,0x65,0x66,0x53, +0x26,0x9a,0x76,0x7a,0xb9,0x75,0x79,0x97, +0x67,0x99,0x98,0x88,0x88,0x86,0x31,0x48, +0x98,0x79,0xee,0xd9,0x66,0x77,0x76,0x52, +0x25,0x8b,0xb9,0xab,0xa9,0x76,0x43,0x35, +0x77,0x57,0xce,0xda,0x99,0x87,0x77,0x54, +0x69,0x97,0x55,0xaa,0x85,0x46,0x9b,0xba, +0x86,0x68,0x99,0x75,0x69,0x78,0x88,0x41, +0x15,0xbb,0x76,0x9c,0xca,0x98,0x77,0x88, +0x86,0x54,0x57,0x87,0x89,0x98,0x87,0x88, +0x88,0x88,0x86,0x55,0x8a,0x87,0x89,0x98, +0x88,0x76,0x67,0x77,0x88,0x88,0x66,0x77, +0x77,0x77,0x88,0x89,0x98,0x89,0x98,0x87, +0x77,0x77,0x77,0x77,0x88,0x87,0x67,0x88, +0x98,0x87,0x77,0x77,0x66,0x89,0x99,0x88, +0x88,0x88,0x77,0x87,0x67,0x77,0x77,0x77, +0x77,0x77,0x99,0x89,0x88,0x88,0x88,0x87, +0x76,0x67,0x77,0x66,0x77,0x66,0x78,0x89, +0x87,0x88,0x88,0x88,0x89,0x87,0x88,0x87, +0x78,0x67,0x77,0x88,0x89,0x87,0x77,0x77, +0x77,0x88,0x88,0x98,0x88,0x98,0x78,0x87, +0x88,0x87,0x77,0x78,0x87,0x78,0x76,0x78, +0x77,0x88,0x78,0x88,0x99,0x89,0x98,0x77, +0x77,0x76,0x67,0x77,0x77,0x67,0x77,0x67, +0x77,0x88,0x88,0x88,0x88,0x98,0x99,0x98, +0x89,0x87,0x77,0x77,0x66,0x77,0x78,0x77, +0x78,0x77,0x88,0x78,0x88,0x89,0x77,0x87, +0x78,0x87,0x78,0x87,0x76,0x78,0x87,0x78, +0x87,0x77,0x77,0x87,0x77,0x88,0x88,0x99, +0x97,0x88,0x78,0x86,0x67,0x76,0x77,0x67, +0x86,0x78,0x77,0x89,0x88,0x87,0x88,0x88, +0x99,0x98,0x98,0x88,0x76,0x77,0x76,0x77, +0x88,0x87,0x77,0x77,0x98,0x77,0x88,0x88, +0x87,0x87,0x88,0x77,0x79,0x98,0x87,0x78, +0x77,0x67,0x77,0x77,0x78,0x76,0x77,0x87, +0x77,0x88,0x98,0x88,0x87,0x89,0x76,0x87, +0x67,0x77,0x77,0x67,0x77,0x67,0x87,0x78, +0x78,0x99,0x88,0x88,0x99,0x88,0x77,0x78, +0x87,0x77,0x89,0x98,0x87,0x87,0x88,0x76, +0x77,0x77,0x77,0x78,0x78,0x87,0x77,0x99, +0x99,0x88,0x98,0x78,0x88,0x88,0x77,0x87, +0x67,0x77,0x77,0x77,0x88,0x77,0x87,0x88, +0x76,0x78,0x87,0x87,0x78,0x88,0x87,0x77, +0x98,0x88,0x77,0x88,0x77,0x77,0x88,0x77, +0x76,0x67,0x77,0x78,0x78,0x99,0x88,0x87, +0x89,0x88,0x88,0x77,0x88,0x78,0x77,0x77, +0x77,0x87,0x78,0x77,0x88,0x66,0x89,0x98, +0x87,0x88,0x78,0x87,0x77,0x78,0x98,0x87, +0x88,0x98,0x66,0x67,0x77,0x76,0x67,0x77, +0x77,0x66,0x78,0x89,0x88,0x89,0x88,0x98, +0x98,0x88,0x87,0x77,0x77,0x88,0x88,0x78, +0x88,0x77,0x77,0x77,0x77,0x77,0x77,0x78, +0x88,0x77,0x7a,0xaa,0xa9,0x88,0x87,0x65, +0x77,0x88,0x88,0x66,0x89,0x9a,0x84,0x98, +0x87,0x66,0x45,0x65,0x76,0x87,0x89,0x99, +0xac,0xb9,0x85,0x57,0x47,0x65,0x54,0x78, +0x77,0xaa,0x9b,0xbc,0xbb,0x96,0x43,0x42, +0x43,0x45,0x67,0x89,0xac,0xab,0x8b,0xa9, +0x97,0x78,0x89,0x8a,0xa8,0x85,0x65,0x56, +0x56,0x55,0x55,0x89,0x89,0x86,0x99,0xbb, +0xa8,0xa9,0x79,0xaa,0x97,0x78,0x66,0x45, +0x68,0x87,0x55,0x44,0x54,0x66,0x68,0x7a, +0xbb,0xaa,0x99,0x9a,0xbd,0xa8,0x55,0x47, +0x66,0x55,0x44,0x45,0x68,0x8a,0x7a,0x97, +0x75,0x89,0x88,0x99,0xaa,0x9a,0x78,0x88, +0x89,0x77,0x54,0x46,0x77,0x99,0xa9,0x78, +0x67,0x78,0x85,0x55,0x66,0x98,0xa9,0x98, +0x88,0x89,0xaa,0x99,0x99,0x88,0x77,0x87, +0x64,0x54,0x58,0x89,0x66,0x45,0x69,0xcd, +0xb8,0x67,0x88,0x97,0x65,0x46,0x78,0x9a, +0xb9,0xb9,0x87,0x79,0xa9,0xaa,0x76,0x65, +0x86,0x65,0x24,0x22,0x54,0x69,0x9a,0xba, +0xc9,0xdc,0x98,0x66,0x97,0x73,0x02,0x28, +0xbb,0xc6,0xb7,0x88,0x7a,0x98,0x87,0x76, +0x78,0x58,0x88,0x85,0x63,0x13,0x59,0xcc, +0xb9,0x89,0xab,0xab,0xa9,0xa6,0x10,0x01, +0x6a,0xff,0xdc,0x98,0x78,0x76,0x55,0x67, +0x77,0x79,0x98,0x87,0x55,0x67,0x9a,0xab, +0x99,0x88,0x87,0x89,0x98,0x50,0x12,0x29, +0xdd,0xdb,0xa5,0x68,0x66,0x68,0x57,0x87, +0x88,0x89,0x76,0x43,0x57,0x9a,0xb9,0x98, +0x98,0x76,0x65,0x88,0x9a,0x60,0x03,0x7e, +0xfe,0xa7,0x75,0x56,0x78,0x99,0x88,0x67, +0x66,0x99,0x85,0x54,0x59,0xbc,0xb9,0x88, +0x88,0x88,0x77,0x89,0x88,0x40,0x36,0xad, +0xee,0x87,0x41,0x46,0x99,0xa9,0x9a,0x77, +0x45,0x79,0x98,0x74,0x57,0x99,0xa9,0x56, +0x88,0x99,0x87,0x77,0x77,0x98,0x11,0x68, +0xef,0xb7,0x46,0x46,0x88,0x89,0x87,0x99, +0x77,0x66,0x77,0x56,0x7a,0xba,0xa6,0x55, +0x68,0xaa,0xa8,0x77,0x88,0x96,0x03,0x79, +0xee,0xb8,0x44,0x25,0x9a,0xaa,0x97,0x76, +0x78,0x88,0x75,0x39,0xbb,0xc8,0x42,0x56, +0x9b,0xa7,0x77,0x67,0x88,0x89,0x60,0x3a, +0xad,0xe7,0x37,0x76,0x89,0x67,0x97,0x69, +0x87,0x78,0x88,0x55,0x67,0xbb,0xa7,0x64, +0x58,0x8a,0xa9,0x77,0x77,0x88,0x41,0x78, +0xdf,0xb8,0x46,0x56,0xa8,0x88,0x98,0x76, +0x65,0x78,0x9a,0x76,0x77,0x78,0x87,0x79, +0x87,0x76,0x67,0x98,0x88,0x66,0x87,0x23, +0xab,0xad,0x84,0x88,0x66,0x86,0x8a,0x86, +0x77,0x67,0x88,0x75,0x57,0x9b,0xa8,0x76, +0x77,0x98,0x98,0x98,0x77,0x77,0x77,0x22, +0xae,0xcb,0x71,0x3a,0xa8,0x97,0x69,0x96, +0x68,0x77,0x99,0x75,0x67,0x89,0x98,0x67, +0x89,0x97,0x57,0x9a,0x87,0x65,0x8a,0x71, +0x17,0xdd,0xb6,0x35,0xaa,0x76,0x79,0xb9, +0x54,0x68,0x97,0x65,0x35,0xde,0x97,0x66, +0x7a,0x74,0x68,0xbb,0x85,0x68,0x76,0x78, +0x88,0x42,0x8d,0x97,0x97,0x59,0xc8,0x58, +0x87,0x77,0x78,0xa8,0x67,0x63,0x5b,0xdb, +0x96,0x57,0x76,0x58,0xaa,0xb9,0x56,0x67, +0x77,0x86,0x65,0xbb,0x94,0x47,0x9b,0xa8, +0x79,0x86,0x56,0x89,0x98,0x77,0x53,0x4c, +0xb6,0x9b,0x88,0x95,0x48,0x86,0x99,0x7a, +0x95,0x58,0x87,0x87,0x43,0x9e,0x95,0x78, +0x8a,0x95,0x69,0x87,0x67,0x78,0x87,0x63, +0x17,0xeb,0x87,0x78,0x86,0x46,0xaa,0x88, +0x68,0x97,0x57,0x89,0x96,0x45,0x99,0x77, +0x8a,0xb9,0x65,0x68,0x98,0x77,0x98,0x65, +0x21,0x7f,0xc8,0xa9,0x77,0x63,0x5a,0xa9, +0x98,0x77,0x76,0x78,0x64,0x6d,0xd8,0x68, +0x88,0x75,0x68,0xa9,0x97,0x87,0x65,0x78, +0x98,0x64,0x8c,0xa6,0x58,0xba,0x86,0x79, +0x85,0x68,0x97,0x78,0x88,0x43,0x69,0x9b, +0xa7,0x78,0x66,0x55,0x7b,0xb9,0x99,0x77, +0x65,0x10,0x5e,0xca,0xaa,0xa8,0x54,0x67, +0x78,0x89,0xa9,0x77,0x76,0x54,0x49,0xb9, +0x9a,0xa9,0x66,0x57,0x76,0x78,0xaa,0x88, +0x78,0x76,0x66,0x46,0xbb,0x68,0xa8,0x98, +0x67,0x88,0x79,0x99,0x98,0x85,0x28,0x95, +0x7a,0x9a,0xa6,0x79,0x67,0x75,0x78,0x76, +0x89,0x78,0x76,0x56,0x77,0x68,0x98,0x79, +0x99,0x96,0x68,0x77,0x76,0x79,0x85,0x7a, +0x87,0x77,0x89,0x97,0x78,0x98,0x67,0x88, +0x77,0x78,0x88,0x88,0x88,0x88,0x77,0x66, +0x76,0x68,0x98,0xa9,0x79,0x97,0x77,0x86, +0x57,0x87,0x77,0x88,0x87,0x79,0x88,0x87, +0x78,0x87,0x88,0x77,0x76,0x67,0x87,0x78, +0x88,0x77,0x78,0x98,0x88,0x88,0x77,0x87, +0x77,0x78,0x99,0x77,0x89,0x87,0x77,0x88, +0x77,0x88,0x88,0x88,0x87,0x66,0x78,0x88, +0x88,0x88,0x77,0x77,0x77,0x88,0x88,0x78, +0x77,0x77,0x76,0x87,0x78,0x87,0x77,0x87, +0x88,0x67,0x87,0x78,0x78,0x87,0x77,0x66, +0x77,0x89,0x77,0x77,0x78,0x78,0x89,0x88, +0x88,0x88,0x87,0x88,0x88,0x88,0xa9,0x87, +0x88,0x78,0x77,0x78,0x98,0x88,0x98,0x78, +0x86,0x78,0x78,0x88,0x77,0x77,0x78,0x77, +0x88,0x98,0x88,0x88,0x77,0x67,0x77,0x88, +0x77,0x88,0x77,0x77,0x77,0x78,0x88,0x67, +0x86,0x67,0x78,0x88,0x87,0x77,0x87,0x78, +0x88,0x76,0x78,0x87,0x79,0x87,0x78,0x77, +0x89,0x88,0x88,0x88,0x77,0x78,0x78,0x98, +0x77,0x77,0x77,0x67,0x98,0x88,0x76,0x68, +0x87,0x77,0x77,0x66,0x87,0x78,0x87,0x78, +0x88,0x88,0x89,0x87,0x87,0x77,0x77,0x88, +0x88,0x98,0x77,0x76,0x68,0x86,0x78,0x87, +0x77,0x78,0x88,0x88,0x77,0x88,0x78,0x88, +0x88,0x77,0x89,0x88,0x87,0x78,0x87,0x77, +0x88,0x88,0x88,0x77,0x77,0x68,0x78,0x99, +0x77,0x66,0x89,0x76,0x77,0x77,0x78,0x88, +0x87,0x77,0x87,0x78,0x89,0x86,0x68,0x87, +0x67,0x68,0x87,0x78,0x88,0x88,0x77,0x78, +0x77,0x89,0x76,0x68,0x87,0x87,0x77,0x78, +0x88,0x88,0x87,0x88,0x88,0x88,0x88,0x77, +0x98,0x77,0x78,0x88,0x88,0x88,0x88,0x77, +0x88,0x78,0x88,0x76,0x78,0x87,0x77,0x77, +0x77,0x76,0x78,0x77,0x88,0x78,0x87,0x88, +0x67,0x88,0x77,0x87,0x77,0x87,0x79,0x88, +0x87,0x78,0x88,0x99,0x87,0x77,0x79,0x87, +0x77,0x78,0x77,0x78,0x77,0x78,0x88,0x87, +0x77,0x78,0x88,0x88,0x77,0x78,0x88,0x78, +0x87,0x77,0x78,0x89,0x99,0x98,0x87,0x78, +0x77,0x87,0x77,0x76,0x67,0x77,0x77,0x89, +0x98,0x77,0x88,0x88,0x88,0x87,0x75,0x67, +0x67,0x96,0x77,0x57,0x88,0x9a,0x9a,0xa9, +0xa9,0x79,0x75,0x55,0x66,0x67,0x67,0x78, +0x99,0x98,0x98,0x88,0x88,0xa8,0x88,0x67, +0x86,0x66,0x88,0x77,0x88,0x77,0x79,0xa7, +0x78,0x98,0x89,0x86,0x88,0x66,0x56,0x78, +0x66,0x88,0x76,0x78,0x87,0x88,0x99,0x89, +0xa9,0x88,0x75,0x57,0x75,0x55,0x67,0x67, +0x88,0x87,0x99,0x99,0xa9,0xa9,0x78,0x74, +0x57,0x65,0x76,0x57,0x87,0x88,0x89,0x89, +0x97,0x89,0x89,0x98,0x89,0x85,0x67,0x66, +0x78,0x88,0x76,0x99,0x78,0x98,0x99,0x99, +0x98,0x98,0x67,0x66,0x77,0x75,0x67,0x66, +0x78,0x88,0x88,0x88,0x89,0xa9,0xa8,0x87, +0x45,0x75,0x67,0x76,0x77,0x67,0x87,0x89, +0x87,0x9b,0xa9,0x99,0x88,0x75,0x67,0x65, +0x56,0x77,0x87,0x88,0x98,0x77,0x89,0xb9, +0xa9,0x88,0x77,0x65,0x66,0x66,0x67,0x75, +0x68,0x88,0x89,0x99,0xaa,0x9a,0x99,0xa9, +0x75,0x56,0x66,0x67,0x67,0x56,0x77,0x89, +0x98,0x89,0x99,0x89,0x99,0x87,0x66,0x67, +0x67,0x76,0x65,0x57,0x89,0x98,0x9a,0xaa, +0xaa,0x9a,0x98,0x77,0x56,0x65,0x46,0x76, +0x57,0x99,0x78,0x78,0x88,0x99,0x99,0x88, +0x77,0x75,0x56,0x77,0x66,0x77,0x77,0x77, +0x89,0xa9,0x89,0xa9,0x99,0x98,0x76,0x56, +0x75,0x66,0x67,0x67,0x76,0x79,0x98,0x9a, +0xa9,0x99,0xaa,0x87,0x65,0x67,0x76,0x66, +0x65,0x57,0x88,0x99,0xaa,0x9a,0x9a,0xaa, +0x97,0x65,0x56,0x56,0x76,0x76,0x67,0x77, +0x78,0x99,0x98,0x99,0x8a,0x99,0x77,0x76, +0x68,0x77,0x67,0x66,0x87,0x78,0x89,0x99, +0x98,0x99,0x88,0x87,0x67,0x75,0x66,0x56, +0x65,0x68,0x66,0x78,0x99,0x99,0x89,0x99, +0x9a,0x87,0x66,0x67,0x66,0x66,0x66,0x76, +0x77,0xab,0xa9,0x99,0x99,0xa8,0x88,0x65, +0x55,0x56,0x66,0x77,0x77,0x68,0x89,0xa9, +0x99,0x99,0x99,0x99,0x66,0x46,0x77,0x67, +0x76,0x67,0x76,0x99,0x99,0x89,0xaa,0x99, +0xa9,0x96,0x66,0x55,0x76,0x57,0x66,0x77, +0x88,0x98,0x9a,0xb9,0x9a,0xaa,0x97,0x55, +0x66,0x57,0x56,0x66,0x76,0x77,0x98,0xaa, +0xb9,0xa9,0xb9,0x95,0x55,0x55,0x45,0x56, +0x67,0x79,0x87,0x88,0x99,0x9b,0x9a,0xaa, +0x97,0x64,0x45,0x56,0x67,0x76,0x67,0x77, +0x88,0xaa,0xba,0xba,0xa9,0xa6,0x67,0x47, +0x24,0x27,0x47,0x87,0xa6,0xa7,0xa9,0xcb, +0xba,0xca,0xa8,0x65,0x46,0x36,0x46,0x58, +0x65,0xa7,0xa8,0xab,0xbb,0xaa,0xaa,0x97, +0x75,0x35,0x33,0x36,0x65,0x98,0xa9,0x98, +0x89,0xaa,0xbb,0xaa,0x86,0x74,0x42,0x45, +0x37,0x58,0x77,0x89,0xa7,0xa9,0xaa,0xba, +0xaa,0x66,0x55,0x43,0x45,0x24,0x47,0x78, +0xb9,0xd8,0x99,0xb9,0xcd,0xc9,0x75,0xa2, +0x53,0x36,0x46,0x4a,0x69,0x8b,0x9a,0xaa, +0xab,0xdb,0xa9,0x64,0xa3,0x32,0x62,0x44, +0x57,0x79,0xac,0xaa,0x99,0xb9,0xcc,0xb6, +0x77,0x64,0x32,0x42,0x44,0x78,0x69,0x9b, +0x98,0xac,0xb8,0xcc,0xa6,0x75,0x83,0x30, +0x44,0x25,0x39,0x58,0x9d,0xba,0xdd,0xda, +0xca,0xc9,0x55,0xa1,0x20,0x61,0x35,0x4a, +0x78,0xbb,0xda,0xdd,0xfa,0xa8,0xc7,0x05, +0x53,0x01,0x43,0x51,0x6b,0xa8,0xbf,0xed, +0xdc,0xea,0x76,0x86,0x05,0x23,0x02,0x36, +0x73,0xac,0xca,0xde,0xdd,0xba,0xb9,0x65, +0x40,0x33,0x30,0x26,0x58,0x6a,0xac,0xce, +0xec,0xcb,0xa9,0x86,0x52,0x03,0x54,0x24, +0x88,0x88,0xdd,0xed,0xdb,0xab,0x87,0x75, +0x54,0x02,0x25,0x22,0x6a,0xab,0xbd,0xdd, +0xba,0x89,0x76,0x54,0x56,0x02,0x37,0x53, +0x6a,0xdc,0xdc,0xdd,0xb9,0x77,0x75,0x43, +0x55,0x16,0x57,0x76,0x87,0xbc,0xcb,0xbb, +0xca,0x65,0x56,0x44,0x45,0x55,0x57,0x78, +0x88,0x9c,0xbb,0xba,0xb9,0x96,0x55,0x78, +0x76,0x42,0x58,0x86,0x67,0x8c,0xcb,0x98, +0x98,0x98,0x65,0x77,0x66,0x65,0x35,0x79, +0x87,0x8a,0xbc,0xa8,0x88,0x78,0x86,0x67, +0x78,0x75,0x36,0x77,0x78,0x76,0x8b,0xcc, +0xa8,0x68,0x87,0x66,0x77,0x68,0x75,0x67, +0x64,0x68,0x78,0x88,0x98,0x88,0x78,0x97, +0x88,0x78,0x98,0x77,0x88,0x89,0x77,0x87, +0x77,0x78,0x99,0x87,0x88,0x77,0x78,0x88, +0x98,0x77,0x77,0x66,0x77,0x87,0x68,0x87, +0x77,0x78,0x88,0x88,0x88,0x88,0x88,0x89, +0x97,0x67,0x76,0x78,0x89,0x97,0x66,0x66, +0x67,0x78,0x99,0x87,0x77,0x78,0x76,0x78, +0x87,0x77,0x67,0x76,0x78,0x77,0x88,0x98, +0x88,0x88,0x99,0x87,0x89,0x88,0x78,0x99, +0x77,0x66,0x66,0x67,0x88,0x88,0x87,0x77, +0x87,0x77,0x78,0x88,0x77,0x88,0x77,0x98, +0x78,0x88,0x88,0x77,0x76,0x77,0x66,0x77, +0x88,0x99,0x98,0x87,0x78,0x77,0x89,0x98, +0x88,0x76,0x67,0x66,0x67,0x88,0x66,0x67, +0x77,0x88,0x88,0x89,0x99,0x98,0x88,0x99, +0x88,0x88,0x87,0x88,0x88,0x97,0x66,0x76, +0x67,0x88,0x78,0x87,0x77,0x88,0x76,0x68, +0x88,0x78,0x88,0x88,0x78,0x77,0x78,0x77, +0x88,0x89,0x88,0x77,0x78,0x78,0x98,0x88, +0x76,0x67,0x76,0x77,0x88,0x87,0x78,0x78, +0x86,0x67,0x99,0x76,0x88,0x88,0x88,0x87, +0x78,0x99,0x88,0x88,0x88,0x87,0x78,0x87, +0x88,0x88,0x97,0x78,0x78,0x78,0x98,0x88, +0x88,0x77,0x67,0x66,0x77,0x76,0x77,0x78, +0x87,0x78,0x87,0x88,0x98,0x88,0x88,0x77, +0x77,0x78,0x77,0x87,0x88,0x76,0x67,0x76, +0x78,0x87,0x78,0x78,0x76,0x76,0x58,0x87, +0x67,0x88,0x78,0x88,0x88,0x78,0x89,0x88, +0x88,0x98,0x88,0x88,0x78,0x88,0x88,0x88, +0x77,0x77,0x76,0x77,0x88,0x78,0x88,0x77, +0x76,0x77,0x77,0x78,0x77,0x88,0x88,0x87, +0x78,0x98,0x88,0x98,0x77,0x78,0x87,0x79, +0x88,0x88,0x87,0x77,0x67,0x67,0x88,0x77, +0x99,0x77,0x77,0x67,0x88,0x77,0x77,0x79, +0x88,0x77,0x88,0x98,0x88,0x88,0x98,0x88, +0x98,0x77,0x88,0x87,0x88,0x87,0x76,0x76, +0x67,0x87,0x78,0x98,0x77,0x77,0x66,0x78, +0x78,0x66,0x88,0x88,0x78,0x78,0x88,0x88, +0x99,0x87,0x88,0x87,0x89,0x98,0x88,0x88, +0x77,0x66,0x77,0x78,0x88,0x89,0x88,0x77, +0x76,0x78,0x86,0x76,0x79,0x98,0x88,0x88, +0x78,0x89,0x88,0x99,0x87,0x77,0x77,0x88, +0x78,0x98,0x98,0x77,0x77,0x76,0x88,0x78, +0x88,0x78,0x67,0x77,0x67,0x77,0x77,0x77, +0x88,0x76,0x78,0x79,0x98,0x89,0x87,0x78, +0x77,0x78,0x97,0x89,0x88,0x87,0x76,0x67, +0x68,0x87,0x88,0x88,0x76,0x77,0x67,0x88, +0x67,0x77,0x89,0x97,0x79,0x98,0x98,0x79, +0x99,0x88,0x77,0x87,0x78,0x88,0x89,0x98, +0x87,0x66,0x76,0x67,0x78,0x88,0x86,0x78, +0x77,0x77,0x77,0x66,0x79,0x88,0x77,0x78, +0x78,0x89,0x98,0x88,0x77,0x78,0x78,0x99, +0x88,0x99,0x97,0x76,0x67,0x77,0x88,0x78, +0x77,0x77,0x76,0x67,0x77,0x66,0x68,0x89, +0x88,0x78,0x88,0x88,0x98,0x88,0x89,0x86, +0x78,0x77,0x87,0x78,0x99,0x78,0x77,0x66, +0x77,0x88,0x88,0x89,0x66,0x77,0x68,0x76, +0x77,0x88,0x88,0x87,0x77,0x88,0x88,0x89, +0x88,0x87,0x57,0x87,0x79,0x88,0x9a,0x88, +0x77,0x66,0x67,0x78,0x88,0x88,0x76,0x77, +0x77,0x87,0x76,0x67,0x88,0x89,0x87,0x78, +0x87,0x89,0x88,0x89,0x77,0x89,0x77,0x88, +0x79,0x88,0x99,0x76,0x66,0x77,0x77,0x88, +0x77,0x78,0x77,0x76,0x67,0x65,0x68,0x87, +0x86,0x68,0x97,0x78,0x99,0x98,0x76,0x77, +0x88,0x88,0x89,0x89,0x98,0x77,0x76,0x68, +0x87,0x89,0x88,0x87,0x77,0x77,0x78,0x66, +0x77,0x98,0x89,0x87,0x88,0x77,0x89,0x98, +0x78,0x87,0x77,0x88,0x89,0x88,0x89,0x98, +0x76,0x66,0x77,0x78,0x88,0x88,0x88,0x76, +0x68,0x76,0x66,0x78,0x88,0x88,0x77,0x78, +0x88,0x98,0x88,0x86,0x66,0x79,0x87,0x89, +0x88,0x88,0x77,0x76,0x78,0x88,0x88,0x88, +0x87,0x77,0x77,0x77,0x66,0x67,0x79,0x89, +0x87,0x88,0x88,0x89,0xa8,0x77,0x76,0x87, +0x99,0xa6,0x87,0x8a,0x78,0x77,0x85,0x69, +0x67,0x87,0x7a,0x99,0x57,0x87,0x77,0x66, +0x96,0x67,0x89,0x78,0x78,0x7a,0x97,0x78, +0x87,0x67,0x78,0x86,0x88,0x87,0x78,0x86, +0x58,0x68,0xaa,0x98,0xaa,0x87,0x75,0x67, +0x68,0x95,0x66,0x66,0x58,0xa7,0x9a,0xab, +0xa8,0x65,0x53,0x57,0x79,0xaa,0xa7,0x55, +0x59,0xad,0xdc,0xb9,0x94,0x41,0x03,0x67, +0xdc,0x79,0x85,0x43,0x59,0xdc,0xbd,0x9a, +0x72,0x10,0x13,0x8c,0xde,0xb6,0x44,0x57, +0xdf,0xdd,0xaa,0xb6,0x00,0x00,0x29,0xcd, +0xe9,0x78,0x88,0xbd,0xa9,0x88,0x76,0x21, +0x00,0x37,0xcd,0xdc,0x99,0x8a,0x9b,0xa9, +0x87,0x74,0x01,0x11,0x69,0xbe,0xed,0x9a, +0x87,0x86,0x78,0x78,0x73,0x20,0x03,0x7b, +0xcf,0xdb,0xb8,0x76,0x66,0x67,0x77,0x63, +0x13,0x47,0xac,0xbd,0xca,0x98,0x75,0x57, +0x8b,0xb8,0x10,0x01,0x59,0xde,0xdc,0x9a, +0x98,0x97,0x55,0x44,0x57,0x66,0x75,0x68, +0x9a,0xdd,0xaa,0x85,0x69,0x8b,0xcb,0x82, +0x00,0x14,0x9c,0xde,0xbb,0xa9,0x76,0x64, +0x45,0x68,0x99,0x77,0x64,0x77,0x9a,0xa8, +0x67,0x67,0xaa,0xab,0x97,0x50,0x01,0x37, +0x9b,0xfd,0xcc,0x97,0x54,0x44,0x66,0x8a, +0xaa,0x75,0x54,0x66,0x9a,0x9a,0x99,0x89, +0xa8,0x88,0x77,0x30,0x22,0x4b,0xcf,0xec, +0xa8,0x65,0x56,0x56,0x78,0x9b,0xb8,0x66, +0x44,0x56,0x9b,0xba,0xa8,0x88,0x99,0xa8, +0x76,0x01,0x23,0x9c,0xce,0xca,0x86,0x55, +0x56,0x57,0x89,0xbb,0xa8,0x43,0x12,0x57, +0xce,0xcc,0xb8,0x65,0x77,0x89,0x77,0x21, +0x43,0xae,0xae,0xc8,0x76,0x65,0x57,0x48, +0xa8,0xba,0x84,0x23,0x15,0xaa,0xcd,0xbb, +0x76,0x56,0x99,0xba,0x72,0x12,0x29,0xdb, +0xec,0x88,0x76,0x56,0x65,0x89,0x9c,0xba, +0x63,0x20,0x37,0x8d,0xeb,0xa8,0x65,0x69, +0x89,0xa7,0x40,0x14,0x5c,0xdd,0xda,0x87, +0x56,0x57,0x76,0x99,0x9b,0xa7,0x44,0x34, +0x79,0xbc,0xca,0x86,0x56,0x89,0x89,0x87, +0x12,0x42,0xcd,0xad,0xb8,0x86,0x55,0x68, +0x7b,0x99,0xc9,0x54,0x32,0x37,0x9a,0xed, +0xaa,0x66,0x67,0x99,0xa8,0x40,0x21,0x5d, +0xbd,0xd9,0x77,0x55,0x67,0x67,0x97,0xaa, +0x98,0x53,0x23,0x68,0xbf,0xcc,0xa6,0x54, +0x68,0x9b,0x98,0x20,0x43,0xae,0xae,0xa7, +0x84,0x55,0x78,0x6a,0x89,0xb8,0x86,0x35, +0x26,0x9a,0xeb,0xa9,0x57,0x79,0xa9,0xb9, +0x51,0x12,0x2a,0xea,0xfb,0x88,0x56,0x66, +0x76,0x98,0x8c,0x97,0x54,0x22,0x56,0xae, +0xbc,0xa6,0x65,0x78,0xa9,0x75,0x02,0x46, +0xed,0xde,0x77,0x64,0x65,0x88,0x69,0x7a, +0xb9,0xa6,0x23,0x03,0x79,0xed,0xcb,0x77, +0x54,0x78,0xa9,0x73,0x14,0x48,0xdb,0xeb, +0x67,0x45,0x79,0x97,0x98,0x69,0x97,0x75, +0x43,0x47,0x8b,0xcb,0xc9,0x65,0x56,0x9a, +0xb9,0x50,0x23,0x4b,0xcd,0xe8,0x87,0x45, +0x68,0x78,0x95,0x78,0x79,0x97,0x55,0x66, +0x9b,0xab,0x97,0x77,0x79,0x99,0x95,0x13, +0x14,0xba,0xff,0x98,0x64,0x54,0x77,0x89, +0x59,0xa8,0xa8,0x65,0x44,0x36,0xaa,0xdc, +0x99,0x66,0x78,0x89,0x71,0x24,0x39,0xcd, +0xfb,0x97,0x34,0x47,0x88,0xb9,0x88,0x78, +0x86,0x64,0x45,0x6a,0xcc,0xc9,0x76,0x56, +0x79,0x97,0x55,0x53,0x8a,0xbf,0xb9,0x74, +0x55,0x78,0x99,0x87,0x97,0x78,0x76,0x76, +0x66,0x89,0xbb,0x98,0x86,0x78,0x88,0x64, +0x33,0x38,0x9b,0xf9,0xa9,0x55,0x36,0x78, +0xa8,0x88,0x78,0x86,0x67,0x66,0x88,0x8a, +0xa9,0x99,0x88,0x76,0x75,0x34,0x34,0x9a, +0xee,0xaa,0x64,0x33,0x66,0xab,0x9a,0x96, +0x64,0x57,0x88,0x99,0x88,0xa8,0x79,0x88, +0x88,0x76,0x33,0x34,0xaa,0xcd,0xaa,0x85, +0x55,0x67,0x8a,0x88,0x95,0x46,0x55,0x88, +0x9b,0xaa,0xa7,0x67,0x88,0x9a,0x97,0x53, +0x32,0x5a,0xad,0xdb,0xa7,0x55,0x58,0x89, +0x87,0x86,0x25,0x65,0xaa,0xbb,0x98,0x74, +0x46,0x88,0xaa,0x99,0x63,0x42,0x39,0x8c, +0xea,0xb9,0x77,0x46,0x68,0x88,0x97,0x44, +0x54,0x9b,0xbc,0xb8,0x87,0x54,0x76,0x79, +0xa8,0x98,0x32,0x34,0x68,0xac,0xcb,0xb9, +0x66,0x76,0x78,0x97,0x64,0x35,0x47,0xaa, +0xcc,0xa9,0x66,0x67,0x9a,0xa9,0x85,0x32, +0x34,0x8b,0xcf,0xea,0xa6,0x43,0x45,0x69, +0x98,0xba,0x77,0x63,0x58,0x8a,0xb9,0x9a, +0x87,0xa9,0x88,0x67,0x51,0x23,0x47,0xdd, +0xce,0xb9,0x85,0x35,0x55,0x78,0x78,0x96, +0x69,0x86,0x97,0x68,0x77,0x99,0x9b,0xba, +0xb9,0x63,0x00,0x01,0x59,0xbf,0xed,0xc9, +0x66,0x56,0x56,0x65,0x77,0x68,0x98,0xaa, +0x89,0x76,0x45,0x67,0xb9,0xac,0xa8,0x75, +0x32,0x14,0x79,0xdd,0xcd,0xb8,0x74,0x55, +0x66,0x67,0x77,0x78,0x8a,0xba,0x88,0x86, +0x66,0x79,0xaa,0xba,0x97,0x32,0x22,0x37, +0xab,0xfd,0xbc,0x85,0x76,0x67,0x87,0x66, +0x43,0x45,0x8a,0xbd,0xc9,0x87,0x67,0x78, +0x89,0x87,0x74,0x23,0x44,0xab,0xce,0xca, +0x96,0x56,0x55,0x87,0x78,0x86,0x43,0x46, +0xbb,0xcd,0xa8,0x76,0x58,0xa9,0xaa,0x85, +0x31,0x03,0x68,0xbe,0xcc,0xd9,0x77,0x55, +0x56,0x56,0x96,0x67,0x66,0x78,0x8a,0xbb, +0x98,0x66,0x78,0x9a,0x98,0x86,0x31,0x23, +0x4a,0xbd,0xeb,0xcb,0x87,0x66,0x44,0x65, +0x67,0x67,0x87,0x9a,0x99,0xa7,0x57,0x75, +0x9a,0x9c,0xca,0x84,0x00,0x03,0x78,0xae, +0xec,0xd9,0x9a,0x76,0x66,0x54,0x55,0x44, +0x66,0xaa,0xad,0xa9,0x97,0x66,0x66,0x7a, +0x99,0x84,0x22,0x14,0x6a,0xdd,0xec,0xa9, +0x77,0x66,0x65,0x56,0x45,0x66,0x77,0xaa, +0xac,0xa9,0x96,0x67,0x67,0x9a,0xa9,0x84, +0x32,0x04,0x67,0xcc,0xef,0xcb,0xa8,0x76, +0x76,0x44,0x45,0x66,0x87,0xaa,0xac,0xaa, +0xa7,0x67,0x66,0x9a,0x98,0x95,0x22,0x02, +0x77,0xbe,0xee,0xdb,0x86,0x65,0x44,0x44, +0x66,0x77,0x89,0x89,0x87,0xa9,0x98,0x8a, +0x87,0x76,0x89,0x88,0x75,0x31,0x33,0x69, +0xcf,0xed,0xea,0x86,0x45,0x43,0x25,0x66, +0x88,0x78,0x87,0x88,0x98,0x9b,0x89,0x87, +0x89,0x88,0x98,0x53,0x11,0x25,0x78,0xff, +0xef,0xd8,0x76,0x43,0x44,0x47,0x76,0x99, +0x87,0x97,0x7a,0x88,0xa9,0x79,0x98,0x88, +0x78,0x87,0x55,0x43,0x46,0x8a,0xbd,0xed, +0xda,0x66,0x44,0x45,0x65,0x78,0x77,0x89, +0x89,0x97,0x98,0x57,0x87,0x89,0x88,0x88, +0x76,0x74,0x24,0x33,0x67,0xae,0xff,0xed, +0x96,0x42,0x24,0x44,0x67,0x77,0x99,0x79, +0x99,0xb9,0x88,0x87,0x68,0x77,0x98,0x88, +0x74,0x32,0x23,0x79,0xbe,0xde,0xdb,0x76, +0x54,0x45,0x55,0x56,0x69,0xbb,0xba,0x87, +0x54,0x66,0x8a,0xab,0xba,0x88,0x86,0x77, +0x75,0x22,0x11,0x47,0x9f,0xff,0xee,0x96, +0x54,0x34,0x45,0x78,0x8a,0xa8,0x77,0x66, +0x77,0x68,0x87,0x9a,0xa8,0x88,0x68,0x76, +0x64,0x34,0x35,0x8a,0xcf,0xdd,0xb7,0x55, +0x43,0x45,0x45,0x78,0x9a,0xba,0xa9,0x76, +0x53,0x45,0x8a,0xbc,0xb9,0x96,0x67,0x67, +0x77,0x54,0x32,0x48,0xac,0xff,0xec,0x85, +0x32,0x33,0x66,0x69,0x98,0xaa,0xaa,0x86, +0x55,0x55,0x79,0xab,0xbb,0xaa,0x86,0x55, +0x57,0x77,0x44,0x54,0x58,0xcd,0xfe,0xba, +0x74,0x32,0x46,0x76,0x68,0x89,0xbb,0xa9, +0x85,0x44,0x33,0x7a,0xbd,0xdb,0xa8,0x66, +0x67,0x56,0x66,0x54,0x44,0x58,0xcd,0xef, +0xca,0x85,0x34,0x54,0x68,0x66,0x76,0x8a, +0xbb,0xa8,0x54,0x43,0x58,0x9c,0xdc,0xcb, +0x86,0x65,0x56,0x75,0x43,0x24,0x49,0xbb, +0xff,0xdd,0x85,0x44,0x44,0x67,0x88,0x67, +0xaa,0xab,0xca,0x86,0x41,0x22,0x48,0xbe, +0xfd,0xca,0x96,0x44,0x34,0x66,0x66,0x88, +0xab,0xab,0x96,0x56,0x67,0x89,0x9b,0xa8, +0x78,0x77,0x78,0x66,0x53,0x24,0x38,0xcc, +0xff,0xca,0x74,0x34,0x56,0x78,0x66,0x55, +0x79,0xbc,0xba,0x86,0x52,0x23,0x59,0xbc, +0xdc,0x97,0x54,0x45,0x56,0x8b,0xab,0xba, +0x88,0x76,0x55,0x45,0x77,0x67,0x88,0xad, +0xca,0xa8,0x54,0x55,0x68,0x89,0xa9,0x76, +0x54,0x56,0x57,0x99,0xbd,0xbc,0xca,0x65, +0x43,0x36,0x78,0x99,0x88,0x98,0x9a,0x86, +0x64,0x25,0x8a,0xdd,0xba,0x85,0x34,0x55, +0x78,0x89,0x85,0x45,0x56,0x9b,0xce,0xc8, +0x76,0x45,0x56,0x89,0x76,0x76,0x79,0xa9, +0x99,0x77,0x65,0x66,0x55,0x67,0x8b,0xbb, +0xdc,0x97,0x44,0x45,0x66,0x76,0x68,0x9b, +0xcc,0xb8,0x53,0x21,0x25,0x9c,0xee,0xdd, +0xa7,0x55,0x45,0x56,0x89,0x88,0x75,0x67, +0x78,0xa9,0xbb,0x87,0x86,0x56,0x77,0x98, +0x67,0x78,0x87,0x89,0x99,0x67,0x77,0x56, +0x54,0x45,0x8b,0xef,0xfc,0x95,0x34,0x44, +0x67,0x66,0x78,0xbd,0xca,0x87,0x32,0x21, +0x35,0x48,0xbc,0xff,0xdc,0xa7,0x55,0x43, +0x56,0x67,0x78,0x99,0x99,0x87,0x55,0x23, +0x56,0xae,0xed,0xca,0x88,0x64,0x55,0x34, +0x67,0x89,0xab,0xba,0x97,0x43,0x33,0x56, +0x7b,0xcc,0xcb,0xb9,0x65,0x55,0x43,0x46, +0x8a,0xbc,0xa9,0x87,0x76,0x66,0x43,0x45, +0x5b,0xcd,0xfd,0xb9,0x64,0x45,0x45,0x54, +0x58,0x9b,0xcb,0xb9,0x64,0x35,0x55,0x54, +0x44,0x7a,0xdf,0xfd,0xa6,0x43,0x56,0x88, +0x87,0x67,0x79,0xcb,0x97,0x44,0x33,0x57, +0x76,0x76,0x69,0xac,0xfe,0xb8,0x64,0x45, +0x67,0x87,0x65,0x65,0x8b,0xcc,0xa8,0x54, +0x34,0x77,0x78,0x65,0x79,0xcf,0xfd,0xb7, +0x32,0x33,0x58,0x9a,0xa8,0x77,0x66,0x88, +0x9a,0xa8,0x75,0x66,0x66,0x67,0x66,0x89, +0xcc,0xbb,0x87,0x55,0x78,0x98,0x97,0x76, +0x68,0x88,0x88,0x65,0x44,0x56,0x7a,0xba, +0x99,0x99,0x99,0x98,0x75,0x55,0x57,0x98, +0x87,0x87,0x78,0x99,0x76,0x54,0x45,0x66, +0x9a,0xac,0xa8,0x99,0x77,0x77,0x66,0x57, +0x98,0x89,0x77,0x77,0x77,0x88,0x75,0x55, +0x67,0x8a,0xaa,0x85,0x54,0x57,0x8b,0xbb, +0xa8,0x77,0x78,0x88,0x98,0x77,0x67,0x67, +0x77,0x88,0x87,0x65,0x44,0x68,0xbd,0xcc, +0xa8,0x77,0x66,0x99,0x87,0x76,0x68,0x88, +0x98,0x76,0x66,0x68,0x87,0x97,0x77,0x77, +0x99,0x88,0x87,0x66,0x77,0x78,0x87,0x89, +0x99,0x99,0xa9,0x77,0x65,0x56,0x76,0x66, +0x55,0x68,0x89,0x99,0x88,0x76,0x66,0x56, +0x77,0x9b,0xcd,0xd9,0x97,0x64,0x67,0x88, +0x98,0x76,0x65,0x79,0x89,0x98,0x67,0x65, +0x78,0x88,0x89,0x88,0x89,0x99,0x88,0x77, +0x87,0x87,0x65,0x56,0x78,0xbc,0xa9,0x98, +0x67,0x77,0x88,0x77,0x76,0x67,0x87,0x79, +0x86,0x77,0x67,0x88,0x77,0x77,0x77,0x77, +0x88,0x98,0x99,0x99,0x99,0x98,0x78,0x67, +0x87,0x66,0x67,0x78,0x88,0x88,0x77,0x77, +0x68,0x88,0x78,0x66,0x86,0x68,0x97,0x78, +0x77,0x88,0x78,0x88,0x77,0x78,0x99,0xa9, +0x87,0x67,0x67,0x87,0x67,0x77,0x87,0x77, +0x87,0x77,0x77,0x87,0x68,0x98,0x78,0x77, +0x99,0x77,0x87,0x88,0x89,0x99,0x87,0x78, +0x88,0x99,0x99,0x86,0x77,0x67,0x65,0x67, +0x67,0x89,0x88,0x87,0x87,0x78,0x77,0x88, +0x77,0x87,0x78,0x88,0x87,0x77,0x88,0x98, +0x88,0x76,0x77,0x88,0x98,0x87,0x67,0x88, +0x88,0x76,0x66,0x78,0x88,0x88,0x77,0x77, +0x77,0x79,0x98,0x78,0x77,0x77,0x77,0x77, +0x78,0x89,0x97,0x88,0x78,0x89,0x99,0x98, +0x77,0x78,0x88,0x87,0x76,0x67,0x88,0x88, +0x98,0x77,0x67,0x88,0x87,0x78,0x77,0x67, +0x88,0x77,0x78,0x88,0x88,0x88,0x77,0x88, +0x98,0x98,0x87,0x77,0x78,0x97,0x77,0x77, +0x88,0x88,0x98,0x77,0x77,0x78,0x78,0x87, +0x67,0x66,0x77,0x77,0x77,0x77,0x77,0x78, +0x87,0x77,0x88,0x99,0x88,0x77,0x77,0x88, +0x77,0x77,0x78,0x88,0x99,0x89,0x88,0x78, +0x87,0x88,0x77,0x77,0x67,0x77,0x77,0x77, +0x78,0x89,0x88,0x77,0x87,0x78,0x88,0x87, +0x77,0x88,0x88,0x77,0x77,0x88,0x89,0x98, +0x88,0x88,0x87,0x78,0x88,0x77,0x87,0x77, +0x77,0x77,0x77,0x78,0x88,0x77,0x78,0x77, +0x78,0x88,0x77,0x78,0x88,0x76,0x66,0x77, +0x78,0x99,0x88,0x87,0x77,0x78,0x98,0x87, +0x78,0x77,0x77,0x78,0x78,0x77,0x88,0x88, +0x88,0x77,0x77,0x88,0x87,0x77,0x88,0x77, +0x77,0x77,0x77,0x88,0x88,0x77,0x77,0x77, +0x88,0x88,0x77,0x77,0x77,0x87,0x77,0x77, +0x77,0x88,0x88,0x88,0x87,0x88,0x88,0x88, +0x88,0x88,0x88,0x77,0x78,0x88,0x88,0x88, +0x87,0x77,0x78,0x87,0x77,0x77,0x77,0x78, +0x77,0x77,0x77,0x78,0x88,0x97,0x77,0x77, +0x78,0x88,0x88,0x88,0x88,0x77,0x78,0x88, +0x88,0x88,0x88,0x78,0x88,0x88,0x88,0x87, +0x78,0x77,0x87,0x77,0x77,0x77,0x78,0x88, +0x87,0x77,0x77,0x88,0x88,0x87,0x88,0x77, +0x77,0x78,0x78,0x88,0x88,0x88,0x78,0x78, +0x88,0x88,0x77,0x88,0x87,0x77,0x78,0x77, +0x88,0x88,0x88,0x77,0x77,0x78,0x88,0x77, +0x88,0x87,0x77,0x78,0x88,0x88,0x88,0x88, +0x77,0x87,0x78,0x88,0x77,0x78,0x87,0x78, +0x77,0x77,0x77,0x78,0x78,0x88,0x77,0x78, +0x88,0x88,0x88,0x87,0x88,0x77,0x88,0x78, +0x88,0x88,0x88,0x77,0x78,0x88,0x77,0x77, +0x78,0x77,0x87,0x77,0x78,0x87,0x88,0x88, +0x77,0x77,0x77,0x88,0x88,0x87,0x77,0x88, +0x77,0x88,0x88,0x88,0x88,0x88,0x87,0x88, +0x88,0x88,0x88,0x88,0x87,0x77,0x77,0x77, +0x88,0x78,0x88,0x77,0x78,0x88,0x88,0x88, +0x77,0x77,0x77,0x77,0x88,0x88,0x88,0x88, +0x87,0x77,0x88,0x77,0x88,0x77,0x77,0x78, +0x77,0x78,0x87,0x78,0x88,0x87,0x77,0x77, +0x88,0x88,0x87,0x77,0x88,0x77,0x88,0x88, +0x88,0x88,0x87,0x87,0x88,0x88,0x88,0x87, +0x77,0x88,0x87,0x78,0x77,0x77,0x77,0x88, +0x87,0x78,0x78,0x88,0x88,0x77,0x88,0x77, +0x87,0x88,0x88,0x87,0x88,0x88,0x78,0x88, +0x78,0x87,0x78,0x88,0x88,0x77,0x78,0x88, +0x77,0x88,0x87,0x77,0x77,0x77,0x88,0x87, +0x78,0x88,0x88,0x88,0x88,0x88,0x88,0x88, +0x88,0x88,0x87,0x88,0x88,0x88,0x88,0x77, +0x77,0x77,0x88,0x77,0x88,0x88,0x88,0x88, +0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88, +0x88,0x88,0x88,0x88 +}; diff --git a/gbdk-lib/examples/ap/scroller/Makefile b/gbdk-lib/examples/ap/scroller/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = text_scroller.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/scroller/text_scroller.c b/gbdk-lib/examples/ap/scroller/text_scroller.c @@ -0,0 +1,72 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> + +#include <gb/bgb_emu.h> + +const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0}; +const uint8_t * scanline_offsets = scanline_offsets_tbl; + +#define SCROLL_POS 15 +#define SCROLL_POS_PIX_START (SCROLL_POS * 8) - 1 +#define SCROLL_POS_PIX_END ((SCROLL_POS + 1) * 8) - 1 + +uint8_t scroller_x = 0; + +void scanline_isr() { + switch (LYC_REG) { + case 0: + SCX_REG = 0; + LYC_REG = SCROLL_POS_PIX_START; + break; + case SCROLL_POS_PIX_START: + SCX_REG = scroller_x; + LYC_REG = SCROLL_POS_PIX_END; + break; + case SCROLL_POS_PIX_END: + SCX_REG = LYC_REG = 0; + break; + } +} + +const uint8_t scroller_text[] = "This is a text scroller demo for GBDK-2020. You can use ideas, that are "\ +"shown in this demo, to make different parallax effects, scrolling of tilemaps which are larger than 32x32 "\ +"tiles and TEXT SCROLLERS, of course! Need to write something else to make this text longer than 256 characters. "\ +"The quick red fox jumps over the lazy brown dog. 0123456789. "; + +const uint8_t * scroller_next_char = scroller_text; +uint8_t * scroller_vram_addr; +uint16_t base, limit; + +void main() { + printf("Scrolling %d chars", sizeof(scroller_text) - 1); + + CRITICAL { + STAT_REG |= STATF_LYC; LYC_REG = 0; + add_LCD(scanline_isr); + set_interrupts(VBL_IFLAG | LCD_IFLAG); + } + + scroller_vram_addr = get_bkg_xy_addr(20, SCROLL_POS); + set_vram_byte(scroller_vram_addr, *scroller_next_char - 0x20); + + base = (uint16_t) scroller_vram_addr & 0xffe0; + limit = base + 0x20; + + while (1) { + scroller_x++; + if ((scroller_x & 0x07) == 0) { + // next letter + scroller_next_char++; + if (*scroller_next_char == 0) scroller_next_char = scroller_text; + + // next vram position + scroller_vram_addr++; + if (scroller_vram_addr == (uint8_t *)limit) scroller_vram_addr = (uint8_t *)base; + + // put next char + set_vram_byte(scroller_vram_addr, *scroller_next_char - 0x20); + } + wait_vbl_done(); + } +} + diff --git a/gbdk-lib/examples/ap/sgb_border/Makefile b/gbdk-lib/examples/ap/sgb_border/Makefile @@ -0,0 +1,11 @@ +CC = ../../../bin/lcc + +all: + $(CC) -mgbz80:ap -Wl-j -Wm-yS -Wm-ys -o border.pocket border.c sgb_border.c border_data.c + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm diff --git a/gbdk-lib/examples/ap/sgb_border/border.c b/gbdk-lib/examples/ap/sgb_border/border.c @@ -0,0 +1,13 @@ +#include <gb/gb.h> +#include <stdint.h> +#include "sgb_border.h" + +#include "border_data.h" + +void main(void) { + DISPLAY_ON; + set_sgb_border(border_chr, border_chr_size, border_map, border_map_size, border_pal, border_pal_size); + while(1) { + wait_vbl_done(); + } +} + diff --git a/gbdk-lib/examples/ap/sgb_border/border_data.c b/gbdk-lib/examples/ap/sgb_border/border_data.c @@ -0,0 +1,192 @@ +const unsigned char border_chr[]={ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00, +0x02,0x02,0x0b,0x08,0x1c,0x13,0x30,0x2f,0x61,0x5f,0x22,0x1e,0xc4,0xbc,0x49,0x39,0xfe,0xfd,0xfb,0xf4,0xfc,0xe0,0xf0,0xc0,0xe0,0x81,0xa0,0xc3,0xc0,0x07,0x40,0x8f, +0x7f,0x80,0x80,0x7f,0x00,0xff,0x38,0xf8,0x80,0x80,0x1c,0x1f,0xc0,0xff,0x00,0xff,0x7f,0x00,0x80,0x00,0x00,0x00,0x00,0x3f,0x00,0xff,0x00,0xfc,0x00,0xc0,0x00,0x00, +0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00, +0xfe,0x01,0x01,0xfe,0x00,0xff,0x1c,0x1f,0x01,0x01,0x38,0xf8,0x03,0xff,0x00,0xff,0xfe,0x00,0x01,0x00,0x00,0x00,0x00,0xfc,0x00,0xff,0x00,0x3f,0x00,0x03,0x00,0x00, +0x40,0x40,0xd0,0x10,0x38,0xc8,0x0c,0xf4,0x86,0xfa,0x44,0x78,0x23,0x3d,0x92,0x9c,0x7f,0xbf,0xdf,0x2f,0x3f,0x07,0x0f,0x03,0x07,0x81,0x05,0xc3,0x03,0xe0,0x02,0xf1, +0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xfe,0xfe,0xfe,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe, +0x4a,0xbb,0x82,0x73,0x90,0x73,0x94,0x77,0x94,0x77,0x84,0x67,0x80,0x67,0x80,0x67,0x40,0x0e,0x80,0x0e,0x80,0x1c,0x80,0x1c,0x80,0x1c,0x80,0x1c,0x80,0x18,0x80,0x18, +0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0xff,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x00, +0x00,0xff,0x00,0xff,0x0e,0xfe,0x09,0xfd,0x09,0xff,0x09,0xfd,0x0e,0xfe,0x00,0xff,0x00,0x00,0x00,0x00,0x06,0x01,0x00,0x02,0x00,0x00,0x00,0x02,0x06,0x01,0x00,0x00, +0x00,0xff,0x00,0xff,0x33,0xb7,0x49,0xcf,0x49,0xff,0x49,0xcf,0x31,0xb7,0x00,0xff,0x00,0x00,0x00,0x00,0x31,0x48,0x00,0x30,0x00,0x00,0x00,0x30,0x30,0x48,0x00,0x00, +0x00,0xff,0x00,0xff,0x81,0xff,0x01,0xfd,0x03,0xff,0x02,0xfe,0x02,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00, +0x00,0xff,0x00,0xff,0x42,0xfa,0x45,0x5d,0xe5,0xf7,0xaf,0xbf,0x28,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x40,0x05,0x05,0xa2,0xe0,0x08,0x0a,0x40,0x00,0x00,0x00,0x00, +0x00,0xff,0x00,0xff,0x3b,0xff,0x12,0xff,0x13,0x7f,0x92,0xff,0x92,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x01,0x80,0x80,0x00,0x00,0x00,0x00,0x00, +0x00,0xff,0x00,0xff,0x94,0xbd,0x52,0x7a,0x91,0xbd,0x92,0xba,0x54,0x7d,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x42,0x02,0x85,0x80,0x42,0x02,0x45,0x00,0x82,0x00,0x00, +0x00,0xff,0x00,0xff,0x41,0x7f,0x81,0xbf,0x01,0x7f,0x80,0xbe,0x40,0x7f,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x40,0x01,0x80,0x80,0x41,0x00,0x80,0x00,0x00, +0x00,0xff,0x00,0xff,0x15,0xff,0x14,0xff,0x54,0x5f,0xa4,0xaf,0xa4,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xa0,0xa0,0x50,0x00,0x00,0x00,0x00, +0x00,0xff,0x00,0xff,0xd2,0xff,0x92,0xff,0x9e,0xff,0x92,0xff,0x92,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0xff,0x00,0xff,0x07,0xf7,0x08,0xfb,0x06,0xf6,0x01,0xfd,0x0e,0xfe,0x00,0xff,0x00,0x00,0x00,0x00,0x05,0x08,0x00,0x04,0x00,0x09,0x00,0x02,0x0a,0x01,0x00,0x00, +0x00,0xff,0x00,0xff,0x77,0xff,0x24,0xff,0x27,0xff,0x24,0xff,0x27,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0xff,0x00,0xff,0x73,0xf7,0x4a,0xef,0x73,0xf7,0x52,0xf7,0x4b,0xef,0x00,0xff,0x00,0x00,0x00,0x00,0x21,0x08,0x00,0x10,0x30,0x08,0x00,0x08,0x01,0x10,0x00,0x00, +0x00,0xff,0x00,0xff,0x98,0xdb,0x24,0xe7,0xa4,0xff,0x24,0xe7,0x98,0xdb,0x00,0xff,0x00,0x00,0x00,0x00,0x18,0x24,0x00,0x18,0x80,0x00,0x00,0x18,0x18,0x24,0x00,0x00, +0x00,0xff,0x00,0xff,0x0e,0xef,0x10,0xf7,0x0c,0xed,0x02,0xfb,0x1c,0xfd,0x00,0xff,0x00,0x00,0x00,0x00,0x0a,0x10,0x00,0x08,0x00,0x12,0x00,0x04,0x14,0x02,0x00,0x00, +0x00,0xff,0x00,0xff,0x64,0x6f,0x94,0x9f,0x94,0xff,0x94,0x9c,0x63,0x6b,0x00,0xff,0x00,0x00,0x00,0x00,0x64,0x90,0x00,0x60,0x00,0x00,0x00,0x63,0x63,0x94,0x00,0x00, +0x00,0xff,0x00,0xff,0xa5,0xff,0xb5,0xff,0xbd,0xff,0xad,0xff,0x25,0x7f,0x00,0xff,0x00,0x00,0x00,0x00,0x84,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x20,0x80,0x00,0x00, +0x00,0xff,0x00,0xff,0xc0,0xdf,0x20,0xbf,0x20,0xff,0x20,0xbf,0xc0,0xdf,0x00,0xff,0x00,0x00,0x00,0x00,0xc0,0x20,0x00,0x40,0x00,0x00,0x00,0x40,0xc0,0x20,0x00,0x00, +0x52,0xdd,0x41,0xce,0x09,0xce,0x29,0xee,0x29,0xee,0x21,0xe6,0x01,0xe6,0x01,0xe6,0x02,0x70,0x01,0x70,0x01,0x38,0x01,0x38,0x01,0x38,0x01,0x38,0x01,0x18,0x01,0x18, +0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7f,0x7f,0x7f,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f, +0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe, +0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18, +0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x01,0xfe,0x03,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00, +0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00, +0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x80,0x7f,0xc0,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00, +0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18, +0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f, +0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00, +0x3c,0xc3,0x78,0x83,0xec,0x00,0xfc,0x00,0xfd,0x01,0x39,0x83,0x02,0x87,0x18,0xdb,0x3c,0x00,0x44,0x10,0x92,0x39,0x82,0x39,0x83,0x10,0x45,0x00,0x3a,0x40,0x18,0x24, +0x00,0xff,0x00,0xff,0xc4,0xd5,0xae,0xff,0xca,0xdf,0xae,0xff,0xca,0xdf,0x00,0xff,0x00,0x00,0x00,0x00,0x40,0x2a,0x2e,0x00,0xc0,0x20,0x2e,0x00,0x40,0x20,0x00,0x00, +0x00,0xff,0x00,0xff,0xee,0xff,0x44,0xff,0x44,0xff,0x44,0xff,0x44,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x00, +0x00,0xff,0x00,0xff,0xee,0xff,0x8a,0xff,0xec,0xfd,0x8a,0xfb,0xea,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x66,0x00,0x00,0x00,0xec,0x02,0x02,0x04,0x60,0x00,0x00,0x00, +0x03,0xfc,0x03,0xfc,0xa3,0xfc,0xa3,0xbc,0xe3,0xfc,0x43,0xfc,0x43,0xfc,0x03,0xfc,0x03,0x00,0x03,0x00,0xa3,0x00,0x03,0x40,0xe3,0x00,0x03,0x00,0x03,0x00,0x03,0x00, +0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, +0x29,0xee,0x2a,0xec,0x2a,0xec,0x0a,0xcc,0x03,0xcd,0x43,0xcd,0x53,0xdd,0x55,0xd9,0x01,0x38,0x02,0x39,0x02,0x39,0x02,0x39,0x03,0x30,0x03,0x70,0x02,0x70,0x04,0x72, +0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x01,0xff,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01, +0x15,0x99,0x06,0x9a,0xa6,0xba,0xaa,0xb2,0x28,0x30,0x0c,0x34,0x4c,0x74,0x54,0x64,0x04,0x72,0x07,0x61,0x07,0xe1,0x09,0xe5,0x0b,0xe7,0x0f,0xc3,0x0f,0xc3,0x13,0xcb, +0x00,0xfe,0x02,0xfe,0x00,0xfc,0x01,0xf9,0x08,0xf9,0x00,0xf3,0x04,0xe7,0x21,0xe6,0x00,0x01,0x00,0x03,0x00,0x03,0x00,0x07,0x00,0x0e,0x00,0x0c,0x00,0x1c,0x01,0x38, +0x10,0x60,0x98,0xe8,0x20,0xc0,0x30,0xd0,0x40,0x80,0x60,0xa0,0xc0,0x40,0x40,0x40,0x17,0x8f,0x1f,0x87,0x2f,0x1f,0x3f,0x0f,0x5f,0x3f,0x5f,0x1f,0xff,0x3f,0x3f,0xbf, +0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xfe,0xfe,0xfe,0xfe, +0x80,0x67,0x80,0x67,0x84,0x67,0x94,0x77,0x94,0x77,0x90,0x73,0x82,0x73,0x4a,0xbb,0x80,0x18,0x80,0x18,0x80,0x1c,0x80,0x1c,0x80,0x1c,0x80,0x1c,0x80,0x0e,0x40,0x0e, +0x03,0xfc,0x01,0xfe,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xff,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x3f,0x80,0x7f,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xc0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, +0x00,0xff,0x00,0xff,0x00,0xfe,0x00,0xfc,0x08,0xf8,0x02,0xe3,0x40,0xc7,0x11,0x1e,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x0f,0x00,0x1e,0x00,0x78,0x01,0xf0, +0x41,0xce,0x93,0x9d,0x27,0x3b,0x4a,0x72,0x14,0xe4,0x28,0xc8,0x70,0xb0,0xc0,0x40,0x01,0x70,0x03,0xf0,0x06,0xe0,0x09,0xc5,0x13,0x0b,0x27,0x17,0x6f,0x0f,0xff,0x3f, +0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x49,0x39,0xc4,0xbc,0x22,0x1e,0x61,0x5f,0x30,0x2f,0x1c,0x13,0x0b,0x08,0x02,0x02,0x40,0x8f,0xc0,0x07,0xa0,0xc3,0xe0,0x81,0xf0,0xc0,0xfc,0xe0,0xfb,0xf4,0xfe,0xfd, +0x00,0xff,0xc0,0xff,0x1c,0x1f,0x80,0x80,0x38,0xf8,0x00,0xff,0x80,0x7f,0x7f,0x80,0x00,0x00,0x00,0xc0,0x00,0xfc,0x00,0xff,0x00,0x3f,0x00,0x00,0x80,0x00,0x7f,0x00, +0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0xff,0x00, +0x00,0xff,0x07,0xff,0xe0,0xe0,0x03,0x03,0xf0,0xff,0x01,0xfe,0x7e,0x80,0x8f,0x0f,0x00,0x00,0x00,0x07,0x00,0xff,0x00,0xff,0x00,0xf0,0x01,0x00,0x7e,0x01,0x8c,0x70, +0x30,0xf0,0x03,0x03,0x38,0x3f,0x81,0xfe,0x1e,0xe0,0xe7,0x07,0x70,0x70,0x80,0x80,0x00,0x3f,0x00,0xff,0x00,0xf8,0x01,0x80,0x1e,0x01,0xe6,0x18,0x6f,0x8f,0x7f,0x7f, +0x42,0x7c,0x0f,0xf3,0x34,0xc4,0xd0,0x10,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xc1,0x0e,0x00,0x33,0x0b,0xdf,0x2f,0x7f,0xbf,0xff,0xff,0xff,0xff,0xff,0xff, +0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xff,0xff,0xfb, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xe3,0xff,0x00,0xf3,0x0c,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9c,0x7f,0xff,0xff,0xf3,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x87,0xcf,0x08,0x87,0x48,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x7f,0xff,0xf7,0xb7,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x80,0x00,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x28,0x70,0x48,0x38,0x40,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7,0xff,0xf7,0xbf,0xbf,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x1c,0x08,0x14,0x3c,0x20,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf3,0xef,0xeb,0xff,0xff,0xdf, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x20,0x3f,0x20,0x1f,0x20,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xff,0xdf,0xdf,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0xf0,0x10,0xd0,0x30,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xef,0xdf,0xef, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x01,0x3f,0x20,0x3b,0x24,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xff,0xff,0xdf,0xfb,0xdf, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xc0,0xc0,0x20,0xe0,0x11,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xff,0xee,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x76,0x7f,0x81,0xff,0x00,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xcb,0xbd,0x7f,0xfe,0xff,0xff, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x38,0x48,0x70,0x48,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xbf,0xf7,0xf7,0xbf, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x24,0x70,0x48,0x38,0x48,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xfb,0xf7,0xbf,0xbf,0xf7, +0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x7c,0x04,0x78,0x04,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xfb,0xfb,0xff, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xec,0x02,0xec,0x02,0xe0,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xff,0xfd,0xff,0xff,0xff, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0xf8,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xff, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x0e,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x0f,0x08,0x0e,0x01,0x0c,0x12,0x1e,0x02,0x38,0x24,0x1c,0x24,0x3c,0x04,0x38,0x00,0xff,0xf7,0xfe,0xff,0xed,0xff,0xff,0xfd,0xfb,0xdf,0xdf,0xfb,0xff,0xfb,0xff,0xff, +0x63,0xe3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x41,0xfe,0x80,0x7f,0x9c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xbf,0xfe,0xff,0x7f, +0x4f,0xc0,0x1f,0x10,0x0f,0x10,0x1d,0x02,0x3f,0x22,0x18,0x25,0x3c,0x05,0x77,0x4f,0x7f,0xbf,0xff,0xef,0xef,0xff,0xfd,0xff,0xff,0xdd,0xda,0xff,0xfe,0xfb,0xf7,0xb8, +0xc0,0x40,0xc0,0x40,0x80,0x40,0x80,0x40,0xc0,0x00,0xe0,0x20,0xe1,0x21,0xc0,0x21,0xff,0xbf,0xff,0xbf,0xbf,0xff,0xbf,0xff,0xff,0xff,0xff,0xdf,0xff,0xde,0xde,0xff, +0x3c,0x44,0x7c,0x04,0xf8,0x84,0x78,0x84,0x7c,0x80,0xdf,0x23,0xde,0x23,0xed,0x32,0xbf,0xfb,0xff,0xfb,0xfb,0x7f,0x7b,0xff,0x7f,0xff,0xdf,0xfc,0xde,0xfd,0xed,0xdf, +0x1c,0x20,0x7e,0x42,0x3e,0x42,0xfe,0x82,0x6c,0x92,0xcc,0x32,0xec,0x32,0x9e,0x50,0xdf,0xff,0xff,0xbd,0xbf,0xfd,0xff,0x7d,0x6d,0xff,0xcd,0xff,0xed,0xdf,0xbf,0xef, +0x1c,0x24,0x1c,0x24,0x38,0x00,0x30,0x08,0x30,0x08,0x7f,0x40,0x7f,0x40,0x7f,0x40,0xdf,0xfb,0xdf,0xfb,0xff,0xff,0xf7,0xff,0xf7,0xff,0xff,0xbf,0xff,0xbf,0xff,0xbf, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x20,0xe0,0x20,0xa0,0x60,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xff,0xff,0xdf,0xbf,0xdf, +0x1c,0x24,0x18,0x20,0x38,0x00,0x30,0x08,0x76,0x4f,0x7f,0x40,0x3f,0x40,0x3f,0x40,0xdf,0xfb,0xdf,0xff,0xff,0xff,0xf7,0xff,0xf6,0xb9,0xff,0xbf,0xbf,0xff,0xbf,0xff, +0x73,0x82,0xf1,0x82,0xf1,0x82,0x67,0x94,0xf3,0x14,0xc3,0x24,0xf3,0x14,0xe7,0x10,0x7f,0xfd,0xfd,0x7f,0xfd,0x7f,0x6f,0xfb,0xfb,0xef,0xdb,0xff,0xfb,0xef,0xef,0xff, +0xe7,0x18,0xe3,0x24,0x87,0x44,0xc3,0x40,0x03,0x80,0x83,0x80,0x83,0x80,0x07,0x04,0xe7,0xff,0xfb,0xdf,0xbf,0xfb,0xff,0xbf,0x7f,0xff,0xff,0x7f,0xff,0x7f,0xff,0xfb, +0xb0,0x88,0x98,0xa0,0x3d,0xa5,0x18,0x85,0x8f,0x12,0x9f,0x10,0x8f,0x00,0x06,0x89,0xf7,0x7f,0xdf,0x7f,0x7f,0xda,0x7a,0xff,0xef,0xfd,0xff,0xef,0xff,0xff,0x76,0xff, +0xe0,0x90,0x70,0x90,0xc0,0x20,0xe0,0x20,0x80,0x40,0xc0,0x40,0x00,0x80,0x80,0x80,0xef,0x7f,0x7f,0xef,0xdf,0xff,0xff,0xdf,0xbf,0xff,0xff,0xbf,0x7f,0xff,0xff,0x7f, +0x76,0x0a,0x7c,0x0a,0x73,0x05,0x76,0x05,0x71,0x02,0x73,0x02,0x70,0x01,0x00,0x00,0xf7,0xfd,0xfd,0xf7,0xfb,0xfe,0xfe,0xfb,0xfd,0xff,0xff,0xfd,0xfe,0xff,0xff,0xff, +0xe0,0x0e,0xee,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0x00,0x00,0xf1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xe8,0x0e,0xfe,0x01,0xee,0x19,0xf7,0x10,0xe7,0x00,0xe7,0x00,0xe7,0x00,0x00,0x00,0xf9,0xf7,0xfe,0xff,0xee,0xf7,0xff,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x61,0x12,0x63,0x14,0x63,0x14,0x67,0x10,0x63,0x14,0x63,0x14,0x61,0x12,0x00,0x00,0xed,0xff,0xeb,0xff,0xeb,0xff,0xef,0xff,0xeb,0xff,0xeb,0xff,0xed,0xff,0xff,0xff, +0xe3,0x10,0xf3,0xc8,0x33,0x08,0xfb,0x00,0x03,0x00,0x53,0x68,0xe3,0x10,0x00,0x00,0xef,0xff,0xf7,0x3f,0xf7,0xff,0xff,0xff,0xff,0xff,0xd7,0xbf,0xef,0xff,0xff,0xff, +0xa0,0x38,0xf8,0x05,0xb8,0x65,0xdd,0x40,0x9c,0x01,0x9c,0x01,0x9c,0x00,0x00,0x00,0xe7,0xdf,0xfa,0xff,0xba,0xdf,0xff,0xbf,0xfe,0xff,0xfe,0xff,0xff,0xff,0xff,0xff, +0x7e,0x80,0xfe,0x30,0xce,0x00,0xce,0x00,0xce,0x00,0xfe,0x30,0x7e,0x80,0x00,0x00,0x7f,0xff,0xff,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xcf,0x7f,0xff,0xff,0xff, +0x3c,0x42,0x7e,0x99,0x66,0x81,0xe7,0x00,0x66,0x81,0x7e,0x99,0x3c,0x42,0x00,0x00,0xbd,0xff,0x7e,0xe7,0x7e,0xff,0xff,0xff,0x7e,0xff,0x7e,0xe7,0xbd,0xff,0xff,0xff, +0x38,0x00,0x3c,0x04,0x3c,0x04,0x18,0x24,0x3d,0x23,0x0f,0x10,0x07,0x08,0x05,0x06,0xff,0xff,0xff,0xfb,0xff,0xfb,0xdb,0xff,0xfd,0xde,0xef,0xff,0xf7,0xff,0xfd,0xfb, +0x7c,0x82,0x0e,0x12,0x1c,0x00,0x38,0x24,0x7c,0x44,0x79,0x81,0xf0,0x09,0xd1,0x30,0x7d,0xff,0xef,0xfd,0xff,0xff,0xfb,0xdf,0xff,0xbb,0x7f,0xfe,0xf6,0xff,0xdf,0xef, +0x3f,0x40,0x7f,0x00,0xef,0x9f,0x70,0x90,0xe0,0x00,0xc0,0x20,0xe0,0x20,0xc0,0x00,0xbf,0xff,0xff,0xff,0xef,0x70,0x7f,0xef,0xff,0xff,0xdf,0xff,0xff,0xdf,0xff,0xff, +0xc0,0x21,0xe1,0x00,0x73,0x92,0x71,0x92,0xe1,0x92,0xe3,0x90,0x7f,0x0c,0x3b,0x4c,0xde,0xff,0xff,0xff,0x7f,0xed,0x7d,0xef,0xed,0x7f,0xef,0x7f,0xff,0xf3,0xbb,0xf7, +0xcd,0x12,0x9f,0x50,0x8f,0x40,0xc6,0x49,0x87,0x09,0x0c,0x8a,0x0e,0x8a,0x80,0x84,0xed,0xff,0xbf,0xef,0xbf,0xff,0xf6,0xbf,0xf7,0xfe,0x7d,0xf7,0x7f,0xf5,0xfb,0x7f, +0xde,0x50,0x0f,0x81,0x8f,0x81,0x07,0x09,0x06,0x09,0x06,0x09,0x0e,0x09,0x0f,0x08,0xff,0xaf,0x7f,0xfe,0xff,0x7e,0xf7,0xfe,0xf6,0xff,0xf6,0xff,0xfe,0xf7,0xff,0xf7, +0x38,0x48,0x38,0x48,0xb0,0xc0,0xe0,0x90,0xe0,0x90,0xff,0x80,0xff,0x80,0xff,0x80,0xbf,0xf7,0xbf,0xf7,0xbf,0x7f,0xef,0x7f,0xef,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0xf0,0x10,0xd0,0x30,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xef,0xdf,0xef, +0x79,0x09,0x78,0x08,0xf0,0x80,0xe0,0x90,0x6d,0x9e,0x7f,0x80,0xff,0x00,0xf9,0x07,0xff,0xf6,0xff,0xf7,0xff,0x7f,0xef,0x7f,0x6d,0xf3,0x7f,0xff,0xff,0xff,0xf9,0xfe, +0x77,0x80,0xf7,0x80,0xf3,0x84,0x63,0x94,0xf7,0x14,0xc3,0x20,0x83,0x42,0x81,0x81,0x7f,0xff,0xff,0x7f,0xfb,0x7f,0x6b,0xff,0xff,0xeb,0xdf,0xff,0xbf,0xfd,0xff,0x7e, +0x07,0x04,0x03,0x04,0x8f,0x88,0x16,0x99,0xaf,0x71,0xfc,0x02,0xf8,0x04,0x48,0xb8,0xff,0xfb,0xfb,0xff,0xff,0x77,0x76,0xef,0xaf,0xde,0xfd,0xff,0xfb,0xff,0x4f,0xf7, +0x0e,0x89,0x8e,0x89,0x87,0x89,0x07,0x09,0x0e,0x00,0x0e,0x00,0x1c,0x12,0x1c,0x12,0x7e,0xf7,0xfe,0x77,0xf7,0x7e,0xf7,0xfe,0xff,0xff,0xff,0xff,0xfd,0xef,0xfd,0xef, +0x00,0x00,0x00,0x00,0x1c,0x22,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x08,0xff,0xff,0xff,0xff,0xdd,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf7,0xff, +0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x50,0xf8,0x20,0xa8,0x50,0xa8,0x00,0x20,0xa8,0xff,0xff,0xff,0xff,0x77,0xff,0xaf,0xff,0xff,0xdf,0xaf,0xff,0xff,0xff,0x77,0xdf, +}; +extern const unsigned int border_chr_size = sizeof(border_chr); +const unsigned char border_map[]={ +0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10, +0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10, +0x00,0x10,0x00,0x10,0x01,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10, +0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x03,0x10,0x00,0x10,0x00,0x10, +0x00,0x10,0x04,0x10,0x05,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10, +0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x07,0x10,0x08,0x10,0x00,0x10, +0x09,0x10,0x0a,0x10,0x0b,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0d,0x10,0x0e,0x10,0x0f,0x10,0x10,0x10,0x11,0x10,0x12,0x10, +0x13,0x10,0x14,0x10,0x15,0x10,0x16,0x10,0x17,0x10,0x18,0x10,0x19,0x10,0x1a,0x10,0x1b,0x10,0x1c,0x10,0x1d,0x10,0x0c,0x10,0x0c,0x10,0x0b,0x10,0x1e,0x10,0x1f,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x22,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10, +0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x24,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x2a,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x2b,0x10,0x2c,0x10,0x2d,0x10,0x2e,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x2f,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x30,0x10,0x31,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x32,0x10,0x33,0x10,0x00,0x10, +0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10, +0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x34,0x10,0x35,0x10,0x00,0x10, +0x36,0x10,0x37,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x38,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10, +0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x3a,0x10,0x3b,0x10,0x3c,0x10,0x3d,0x10,0x3e,0x10,0x00,0x10, +0x00,0x10,0x3f,0x10,0x40,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10, +0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x42,0x10,0x43,0x10,0x44,0x10,0x45,0x10,0x00,0x10,0x00,0x10, +0x00,0x10,0x00,0x10,0x46,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x48,0x10,0x49,0x10,0x4a,0x10,0x4b,0x10,0x4c,0x10,0x4d,0x10, +0x4e,0x10,0x4f,0x10,0x50,0x10,0x51,0x10,0x52,0x10,0x53,0x10,0x54,0x10,0x47,0x10,0x47,0x10,0x55,0x10,0x56,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10, +0x00,0x10,0x00,0x10,0x57,0x10,0x58,0x10,0x00,0x10,0x59,0x10,0x00,0x10,0x00,0x10,0x5a,0x10,0x00,0x10,0x5b,0x10,0x5c,0x10,0x5d,0x10,0x5e,0x10,0x5f,0x10,0x60,0x10, +0x61,0x10,0x62,0x10,0x63,0x10,0x64,0x10,0x65,0x10,0x66,0x10,0x67,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10, +0x00,0x10,0x00,0x10,0x68,0x10,0x69,0x10,0x6a,0x10,0x6b,0x10,0x6c,0x10,0x6d,0x10,0x6e,0x10,0x6f,0x10,0x70,0x10,0x71,0x10,0x72,0x10,0x73,0x10,0x74,0x10,0x75,0x10, +0x76,0x10,0x77,0x10,0x78,0x10,0x79,0x10,0x7a,0x10,0x7b,0x10,0x7c,0x10,0x7d,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10, +}; +extern const unsigned int border_map_size = sizeof(border_map); +const unsigned char border_pal[]={ +0x1f,0x7c,0x98,0x39,0xad,0x3d,0x19,0x63,0x11,0x31,0x49,0x1d,0xed,0x2c,0x94,0x52,0xef,0x45,0xdf,0x59,0xab,0x51,0xce,0x41,0x7c,0x73,0x06,0x3d,0x1f,0x7c,0x1f,0x7c, +}; +extern const unsigned int border_pal_size = sizeof(border_pal); diff --git a/gbdk-lib/examples/ap/sgb_border/border_data.h b/gbdk-lib/examples/ap/sgb_border/border_data.h @@ -0,0 +1,14 @@ +#ifndef __SGB_BORDER_DATA_H_INCLUDE +#define __SGB_BORDER_DATA_H_INCLUDE + +#include <gb/gb.h> +#include <stdint.h> + +extern const unsigned char border_chr[]; +extern const unsigned int border_chr_size; +extern const unsigned char border_map[]; +extern const unsigned int border_map_size; +extern const unsigned char border_pal[]; +extern const unsigned int border_pal_size; + +#endif + diff --git a/gbdk-lib/examples/ap/sgb_border/sgb_border.c b/gbdk-lib/examples/ap/sgb_border/sgb_border.c @@ -0,0 +1,69 @@ +#include "sgb_border.h" + +#include <gb/gb.h> +#include <stdint.h> +#include <gb/sgb.h> +#include <string.h> + +#define SGB_CHR_BLOCK0 0 +#define SGB_CHR_BLOCK1 1 + +#define SGB_SCR_FREEZE 1 +#define SGB_SCR_UNFREEZE 0 + +#define SGB_TRANSFER(A,B) map_buf[0]=(A),map_buf[1]=(B),sgb_transfer(map_buf) + +void set_sgb_border(unsigned char * tiledata, size_t tiledata_size, + unsigned char * tilemap, size_t tilemap_size, + unsigned char * palette, size_t palette_size) { + if (sgb_check()) { + unsigned char map_buf[20]; + memset(map_buf, 0, sizeof(map_buf)); + + SGB_TRANSFER((SGB_MASK_EN << 3) | 1, SGB_SCR_FREEZE); + + BGP_REG = OBP0_REG = OBP1_REG = 0xE4U; + SCX_REG = SCY_REG = 0U; + + uint8_t tmp_lcdc = LCDC_REG; + + HIDE_SPRITES, HIDE_WIN, SHOW_BKG; + DISPLAY_ON; + // prepare tilemap for SGB_BORDER_CHR_TRN (should display all 256 tiles) + uint8_t i = 0U; + for (uint8_t y = 0; y != 14U; ++y) { + uint8_t * dout = map_buf; + for (uint8_t x = 0U; x != 20U; ++x) { + *dout++ = i++; + } + set_bkg_tiles(0, y, 20, 1, map_buf); + } + memset(map_buf, 0, sizeof(map_buf)); + + // transfer tile data + uint8_t ntiles = (tiledata_size > 256 * 32) ? 0 : tiledata_size >> 5; + if ((!ntiles) || (ntiles > 128U)) { + set_bkg_data(0, 0, tiledata); + SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK0); + if (ntiles) ntiles -= 128U; + tiledata += (128 * 32); + set_bkg_data(0, ntiles << 1, tiledata); + SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK1); + } else { + set_bkg_data(0, ntiles << 1, tiledata); + SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK0); + } + + // transfer map and palettes + set_bkg_data(0, (uint8_t)(tilemap_size >> 4), tilemap); + set_bkg_data(128, (uint8_t)(palette_size >> 4), palette); + SGB_TRANSFER((SGB_PCT_TRN << 3) | 1, 0); + + LCDC_REG = tmp_lcdc; + + // clear SCREEN + fill_bkg_rect(0, 0, 20, 18, 0); + + SGB_TRANSFER((SGB_MASK_EN << 3) | 1, SGB_SCR_UNFREEZE); + } +} diff --git a/gbdk-lib/examples/ap/sgb_border/sgb_border.h b/gbdk-lib/examples/ap/sgb_border/sgb_border.h @@ -0,0 +1,15 @@ +#ifndef __SGB_BORDER_H_INCLUDE +#define __SGB_BORDER_H_INCLUDE + +#include <gb/gb.h> +#include <stdint.h> + +#define SNES_RGB(R,G,B) (uint16_t)((B) << 10 | (G) << 5 | (R)) + +/** sets SGB border */ + +void set_sgb_border(unsigned char * tiledata, size_t tiledata_size, + unsigned char * tilemap, size_t tilemap_size, + unsigned char * palette, size_t palette_size); + +#endif + diff --git a/gbdk-lib/examples/ap/sgb_multiplayer/Makefile b/gbdk-lib/examples/ap/sgb_multiplayer/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS -Wm-ys + +BINS = sgb_multiplayer.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/sgb_multiplayer/sgb_multiplayer.c b/gbdk-lib/examples/ap/sgb_multiplayer/sgb_multiplayer.c @@ -0,0 +1,43 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <gb/sgb.h> + +uint8_t sprite_data[] = { + 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0xA9,0xFF,0x89,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0xB9,0xFF,0x89,0xFF,0x91,0xFF,0xB9,0xFF,0x42,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0x89,0xFF,0x99,0xFF,0x89,0xFF,0x5A,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0xA9,0xFF,0xA9,0xFF,0xB9,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C +}; + +joypads_t joypads; + +void main(void) { + BGP_REG = OBP0_REG = OBP1_REG = 0xE4; + set_sprite_data(0, 4, sprite_data); + for (uint8_t i = 0; i < 4; i++) { + set_sprite_tile(i, i); + move_sprite(i, (i << 3) + 64, 64); + } + SHOW_SPRITES; + + // init joypads + joypad_init(4, &joypads); + + while(1) { + // poll joypads + joypad_ex(&joypads); + // iterate joypads, move sprites + for (uint8_t i = 0; i < joypads.npads; i++) { + uint8_t joy = joypads.joypads[i]; + if (joy & J_LEFT) scroll_sprite(i, -1, 0); + if (joy & J_RIGHT) scroll_sprite(i, 1, 0); + if (joy & J_UP) scroll_sprite(i, 0, -1); + if (joy & J_DOWN) scroll_sprite(i, 0, 1); + } + // start on joypad 1 resets position + if (joypads.joy0 & J_START) { + for (uint8_t i = 0; i < 4; i++) move_sprite(i, (i << 3) + 64, 64); + } + wait_vbl_done(); + } +} + diff --git a/gbdk-lib/examples/ap/sgb_pong/Makefile b/gbdk-lib/examples/ap/sgb_pong/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS -Wm-ys + +BINS = sgb_pong.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/sgb_pong/sgb_pong.c b/gbdk-lib/examples/ap/sgb_pong/sgb_pong.c @@ -0,0 +1,144 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <gb/sgb.h> + +#include <stdio.h> +#include <gb/console.h> + +uint8_t sprite_data[] = { + 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0xA9,0xFF,0x89,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0xB9,0xFF,0x89,0xFF,0x91,0xFF,0xB9,0xFF,0x42,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0x89,0xFF,0x99,0xFF,0x89,0xFF,0x5A,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0xA9,0xFF,0xA9,0xFF,0xB9,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C + +}; + +// initializes sprites for pad. every pad uses 3 sprites which id's are aligned by 4 +void init_pad(uint8_t n) { + set_sprite_tile(n << 2, n); + set_sprite_tile((n << 2) + 1, n); + set_sprite_tile((n << 2) + 2, n); +} + +// inline function for moving pads; code of this function will be inlined with the code of main() +inline void draw_pad(uint8_t n, uint8_t x, uint8_t y) { + move_sprite(n << 2, x, y); + move_sprite((n << 2) + 1, x, y + 8); + move_sprite((n << 2) + 2, x, y + 16); +} + +joypads_t joypads; + +// absolute Y coordinates of player 1 & 2 +uint8_t player1, player2; +uint16_t player1_score, player2_score; + +// player constraints +#define YMIN 28 +#define YMAX 100 +#define PLAYER1_X 16 +#define PLAYER2_X (uint8_t)((20 * 8) - 8) + +// coordinates and speeds of ball +uint8_t ballX, ballY; +int8_t spd_ballX, spd_ballY; + +#define INITBALLX 80 + 4 +#define INITBALLY 64 + 8 + +const unsigned char HUD[] = " p1: %d p2: %d"; + +// main funxction +void main(void) { + // init palettes + BGP_REG = OBP0_REG = OBP1_REG = 0xE4; + + // load tile data into VRAM + set_sprite_data(0, 4, sprite_data); + + // init pad sprites + init_pad(0); + init_pad(1); + + // init ball sprite + set_sprite_tile(3, 2); + + // show bkg and sprites + SHOW_BKG; SHOW_SPRITES; + + // init 2 joypads + if (joypad_init(2, &joypads) != 2) { + printf(" This program must\n be executed on\n Super GameBoy"); + return; + } + + // init players + player1 = 64, player2 = 64; + player1_score = player2_score = 0; + + // draw score + printf(HUD, player1_score, player2_score); + + // init ball + ballX = INITBALLX, ballY = INITBALLY; + spd_ballX = 1, spd_ballY = 1; + + while(1) { + // poll joypads + joypad_ex(&joypads); + + // player 1 + if (joypads.joy0 & J_UP) { + player1 -= 2; + if (player1 < YMIN) player1 = YMIN; + } else if (joypads.joy0 & J_DOWN) { + player1 += 2; + if (player1 > YMAX) player1 = YMAX; + } + draw_pad(0, PLAYER1_X, player1); + + // player 2 + if (joypads.joy1 & J_UP) { + player2 -= 2; + if (player2 < YMIN) player2 = YMIN; + } else if (joypads.joy1 & J_DOWN) { + player2 += 2; + if (player2 > YMAX) player2 = YMAX; + } + draw_pad(1, PLAYER2_X, player2); + + // move ball + ballX += spd_ballX, ballY += spd_ballY; + // check bounce from limits + if ((ballY < YMIN) || (ballY > (YMAX + 24))) { + spd_ballY = -spd_ballY; + } + // check bounce from bats + if (ballX < (PLAYER1_X + 8)) { + if ((ballY > player1) && (ballY < (player1 + 24)) && (spd_ballX < 0)) + spd_ballX = -spd_ballX; + } else if (ballX > (PLAYER2_X - 8)) { + if ((ballY > player2) && (ballY < (player2 + 24)) && (spd_ballX > 0)) + spd_ballX = -spd_ballX; + } + // check player1 or 2 wins, update scores, start from center + if (ballX < PLAYER1_X) { + // player2 wins + ballX = INITBALLX, ballY = INITBALLY; + spd_ballX = -spd_ballX; + player2_score++; + gotoxy(0, 0); printf(HUD, player1_score, player2_score); + } else if (ballX > PLAYER2_X) { + // player1 wins + ballX = INITBALLX, ballY = INITBALLY; + spd_ballX = -spd_ballX; + player1_score++; + gotoxy(0, 0); printf(HUD, player1_score, player2_score); + } + // move ball sprite + move_sprite(3, ballX, ballY); + + // wait for VBlank to slow down everything + wait_vbl_done(); + } +} + diff --git a/gbdk-lib/examples/ap/sound/Makefile b/gbdk-lib/examples/ap/sound/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = sound.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/sound/readme.md b/gbdk-lib/examples/ap/sound/readme.md @@ -0,0 +1,13 @@ +Updated version of the original Sound Sample that merges +in changes made at: https://github.com/gbdk-2020/GBSoundDemo + +Keys: +- Select: change current channel menu +- Start: play current Sound +- Start + A: play a song +- Arrows: navigate throught options +- Arrows + A: Increments/Decrements current value by 10 +- Arrows + B: Increments/Decrements current value by 100 +- Arrows + A + B: set Min/Max value to current option +- Select + A: Dump Registers + diff --git a/gbdk-lib/examples/ap/sound/sound.c b/gbdk-lib/examples/ap/sound/sound.c @@ -0,0 +1,1067 @@ +#include <gb/gb.h> +#include <stdint.h> +#include <stdio.h> +#include <gb/console.h> + +#define ARROW_CHAR '>' +#define SPACE_CHAR ' ' + +#define ARROW_X 0 +#define VAL_X 15 +#define TITLE_Y 0 +#define FIRST_X (ARROW_X+1) +#define FIRST_Y (TITLE_Y+2) + +#define PLAY 0x20 +#define FREQUENCY 0x21 + +#define MIN(x,y) ((x) > (y) ? (y) : (x)) +#define MAX(x,y) ((x) < (y) ? (y) : (x)) + +#define NB_MODES 5 + +#define UNSIGNED 0 + +uint8_t previous_keys = 0; +int8_t keys = 0; +#define UPDATE_KEYS() previous_keys = keys; keys = joypad() +#define KEY_PRESSED(K) (keys & (K)) +#define KEY_TICKED(K) ((keys & (K)) && !(previous_keys & (K))) + +void show_register_channel(uint8_t mode); + +void clss() { + uint8_t i = 0; + for(i = 0; i < 18; ++i) { + gotoxy(0, i); + printf(" "); + } +} + +void print(const char* str) { + printf("%s", str); +} + +const char hex[] = "0123456789ABCDEF"; +void printn(uint16_t n, uint8_t base, uint8_t sign) { + (void) sign; + if(base == 16u) { + printf("%c", hex[0x000Fu & (n >> 4u)]); + printf("%c", hex[0x000Fu & (n)]); + } else { + printf("%d", n); + } +} + + +void println(uint16_t n, uint8_t base, uint8_t sign) { + printn(n, base, sign); + printf("\n"); +} + +enum notes { + C0, Cd0, D0, Dd0, E0, F0, Fd0, G0, Gd0, A0, Ad0, B0, + C1, Cd1, D1, Dd1, E1, F1, Fd1, G1, Gd1, A1, Ad1, B1, + C2, Cd2, D2, Dd2, E2, F2, Fd2, G2, Gd2, A2, Ad2, B2, + C3, Cd3, D3, Dd3, E3, F3, Fd3, G3, Gd3, A3, Ad3, B3, + C4, Cd4, D4, Dd4, E4, F4, Fd4, G4, Gd4, A4, Ad4, B4, + C5, Cd5, D5, Dd5, E5, F5, Fd5, G5, Gd5, A5, Ad5, B5, + SILENCE, END +}; + +const uint16_t frequencies[] = { + 44, 156, 262, 363, 457, 547, 631, 710, 786, 854, 923, 986, + 1046, 1102, 1155, 1205, 1253, 1297, 1339, 1379, 1417, 1452, 1486, 1517, + 1546, 1575, 1602, 1627, 1650, 1673, 1694, 1714, 1732, 1750, 1767, 1783, + 1798, 1812, 1825, 1837, 1849, 1860, 1871, 1881, 1890, 1899, 1907, 1915, + 1923, 1930, 1936, 1943, 1949, 1954, 1959, 1964, 1969, 1974, 1978, 1982, + 1985, 1988, 1992, 1995, 1998, 2001, 2004, 2006, 2009, 2011, 2013, 2015 +}; + +const uint8_t music[] = { + C3, C3, G3, G3, A3, A3, G3, SILENCE, + F3, F3, E3, E3, D3, D3, C3, SILENCE, + G3, G3, F3, F3, E3, E3, D3, D3, + G3, G3, F3, F3, E3, E3, D3, D3, + C3, C3, G3, G3, A3, A3, G3, SILENCE, + F3, F3, E3, E3, D3, D3, C3, SILENCE, + END +}; + +struct Params { + char *name; + uint16_t max; +}; + +const struct Params params_0[] = { + { "Main Controls" , 0 }, + { "All On/Off" , 1 }, + { "Vin->SO1" , 1 }, + { "Vin->SO2" , 1 }, + { "SO1 Volume" , 7 }, + { "SO2 Volume" , 7 }, + { NULL , 0 } +}; + +const struct Params params_1[] = { + { "Sound Mode #1" , 0 }, + { "Swp Time" , 7 }, + { "Swp Mode" , 1 }, + { "Swp Shifts" , 7 }, + { "Pat Duty" , 3 }, + { "Sound Len" , 63 }, + { "Env Init" , 15 }, + { "Env Mode" , 1 }, + { "Env Nb Swp" , 7 }, + { "Frequency" , 2047 }, + { "Cons Sel" , 1 }, + { "Out to SO1" , 1 }, + { "Out to SO2" , 1 }, + { "On/Off" , 1 }, + { NULL , 0 } +}; + +const struct Params params_2[] = { + { "Sound Mode #2" , 0 }, + { "Pat Duty" , 3 }, + { "Sound Len" , 63 }, + { "Env Init" , 15 }, + { "Env Mode" , 1 }, + { "Env Nb Step" , 7 }, + { "Frequency" , 2047 }, + { "Cons Sel" , 1 }, + { "Out to SO1" , 1 }, + { "Out to SO2" , 1 }, + { "On/Off" , 1 }, + { NULL , 0 } +}; + +const struct Params params_3[] = { + { "Sound Mode #3" , 0 }, + { "Sound On/Off" , 1 }, + { "Sound Len" , 255 }, + { "Sel Out Level" , 3 }, + { "Frequency" , 2047 }, + { "Cons Sel" , 1 }, + { "Out to SO1" , 1 }, + { "Out to SO2" , 1 }, + { "On/Off" , 1 }, + { NULL , 0 } +}; + +const struct Params params_4[] = { + { "Sound Mode #4" , 0 }, + { "Sound Len" , 63 }, + { "Env Init" , 15 }, + { "Env Mode" , 1 }, + { "Env Nb Step" , 7 }, + { "Poly Cnt Freq" , 15 }, + { "Poly Cnt Step" , 1 }, + { "Poly Cnt Div" , 7 }, + { "Cons Sel" , 1 }, + { "Out to SO1" , 1 }, + { "Out to SO2" , 1 }, + { "On/Off" , 1 }, + { NULL , 0 } +}; + +const struct Params *params_array[] = { + params_0, + params_1, + params_2, + params_3, + params_4, +}; + +const struct Params *params; + +struct SoundReg { + struct { + //NR10 0xFF10 + uint16_t sweepShifts ;//: 3; + uint16_t sweepMode ;//: 1; + uint16_t sweepTime ;//: 3; + uint16_t unused_1 ;//: 1; + + //NR11 0xFF11 + uint16_t soundLength ;//: 6; + uint16_t patternDuty ;//: 2; + + //NR12 0xFF12 + uint16_t envNbSweep ;//: 3; + uint16_t envMode ;//: 1; + uint16_t envInitialValue ;//: 4; + + //NR13 0xFF13 + uint16_t frequencyLow; + + //NR14 0xFF14 + uint16_t frequencyHigh ;//: 3; + uint16_t unused_2 ;//: 3; + uint16_t counter_ConsSel ;//: 1; + uint16_t restart ;//: 1; + } mode1; + struct { + //NR20 0xFF15 + uint16_t unused_1; + + //NR21 0xFF16 + uint16_t soundLength ;//: 6; + uint16_t patternDuty ;//: 2; + + //NR22 0xFF17 + uint16_t envNbStep ;//: 3; + uint16_t envMode ;//: 1; + uint16_t envInitialValue ;//: 4; + + //NR23 0xFF18 + uint16_t frequencyLow; + + //NR24 0xFF19 + uint16_t frequencyHigh ;//: 3; + uint16_t unused_2 ;//: 3; + uint16_t counter_ConsSel ;//: 1; + uint16_t restart ;//: 1; + } mode2; + struct { + //NR30 0xFF1A + uint16_t unused_1 ;//: 7; + uint16_t on_Off ;//: 1; + + //NR31 0xFF1B + uint16_t soundLength; + + //NR32 0xFF1C + uint16_t unused_2 ;//: 5; + uint16_t selOutputLevel ;//: 2; + uint16_t unused_3 ;//: 1; + + //NR33 0xFF1D + uint16_t frequencyLow; + + //NR34 0xFF1E + uint16_t frequencyHigh ;//: 3; + uint16_t unused_4 ;//: 3; + uint16_t counter_ConsSel ;//: 1; + uint16_t restart ;//: 1; + } mode3; + struct { + //NR40 0xFF1F + uint16_t unused_1; + + //NR41 0xFF20 + uint16_t soundLength ;//: 6; + uint16_t unused_2 ;//: 2; + + //NR42 0xFF21 + uint16_t envNbStep ;//: 3; + uint16_t envMode ;//: 1; + uint16_t envInitialValue ;//: 4; + + //NR43 0xFF22 + uint16_t polyCounterDiv ;//: 3; + uint16_t polyCounterStep ;//: 1; + uint16_t polyCounterFreq ;//: 4; + + //NR44 0xFF23 + uint16_t unused_3 ;//: 6; + uint16_t counter_ConsSel ;//: 1; + uint16_t restart ;//: 1; + } mode4; + struct { + // NR50 0xFF24 + uint16_t SO1_OutputLevel ;//: 3; + uint16_t Vin_SO1 ;//: 1; + uint16_t SO2_OutputLevel ;//: 3; + uint16_t Vin_SO2 ;//: 1; + + // NR51 0xFF25 + uint16_t Sound1_To_SO1 ;//: 1; + uint16_t Sound2_To_SO1 ;//: 1; + uint16_t Sound3_To_SO1 ;//: 1; + uint16_t Sound4_To_SO1 ;//: 1; + uint16_t Sound1_To_SO2 ;//: 1; + uint16_t Sound2_To_SO2 ;//: 1; + uint16_t Sound3_To_SO2 ;//: 1; + uint16_t Sound4_To_SO2 ;//: 1; + + // NR52 0xFF26 + uint16_t Sound1_On_Off ;//: 1; + uint16_t Sound2_On_Off ;//: 1; + uint16_t Sound3_On_Off ;//: 1; + uint16_t Sound4_On_Off ;//: 1; + uint16_t unused_1 ;//: 3; + uint16_t global_On_Off ;//: 1; + } control; +}; + +struct SoundReg *soundReg; + +struct SoundReg s = { + { 0u, 0u, 0u, 0u, + 1, 2, + 3, 0, 4, + 0x73U, + 6, 0, 0, 0 }, + { 0, + 1, 2, + 4, 0, 8, + 0xD7U, + 6, 0, 0, 0 }, + { 0, 1, + 0, + 0, 3, 0, + 0xD6U, + 6, 0, 1, 0 }, + { 0, + 58, 0, + 1, 0, 10, + 0, 0, 0, + 0, 1, 0 }, + { 7, 0, 7, 0, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 1 } +}; + +uint8_t NR10() { + return soundReg->mode1.sweepShifts | (soundReg->mode1.sweepMode << 3) | (soundReg->mode1.sweepTime << 4); +} + +uint8_t NR11() { + return soundReg->mode1.soundLength | (soundReg->mode1.patternDuty << 6); +} + +uint8_t NR12() { + return soundReg->mode1.envNbSweep | (soundReg->mode1.envMode << 3) | (soundReg->mode1.envInitialValue << 4); +} + +uint8_t NR13() { + return soundReg->mode1.frequencyLow; +} + +uint8_t NR14() { + return soundReg->mode1.frequencyHigh | (soundReg->mode1.counter_ConsSel << 6) | (soundReg->mode1.restart << 7); +} + +//-------------------------- +uint8_t NR21() { + return soundReg->mode2.soundLength | (soundReg->mode2.patternDuty << 6); +} + +uint8_t NR22() { + return soundReg->mode2.envNbStep | (soundReg->mode2.envMode << 3) | (soundReg->mode2.envInitialValue << 4); +} + +uint8_t NR23() { + return soundReg->mode2.frequencyLow; +} + +uint8_t NR24() { + return soundReg->mode2.frequencyHigh | (soundReg->mode2.counter_ConsSel << 6) | (soundReg->mode2.restart << 7); +} + +//------------------------------- +uint8_t NR30() { + return soundReg->mode3.on_Off << 7; +} + +uint8_t NR31() { + return soundReg->mode3.soundLength; +} + +uint8_t NR32() { + return soundReg->mode3.selOutputLevel << 5; +} + +uint8_t NR33() { + return soundReg->mode3.frequencyLow; +} + +uint8_t NR34() { + return soundReg->mode3.frequencyHigh | (soundReg->mode3.counter_ConsSel << 6) | (soundReg->mode3.restart << 7); +} + +//------------------------------- +uint8_t NR41() { + return soundReg->mode4.soundLength; +} + +uint8_t NR42() { + return soundReg->mode4.envNbStep | (soundReg->mode4.envMode << 3) | (soundReg->mode4.envInitialValue << 4); +} + +uint8_t NR43() { + return soundReg->mode4.polyCounterDiv | (soundReg->mode4.polyCounterStep << 3) | (soundReg->mode4.polyCounterFreq << 4); +} + +uint8_t NR44() { + return (soundReg->mode4.counter_ConsSel << 6) | (soundReg->mode4.restart << 7); +} + +//------------------------------- +uint8_t NR50() { + return soundReg->control.SO1_OutputLevel | (soundReg->control.Vin_SO1 << 3u) | (soundReg->control.SO2_OutputLevel << 4u) | + (soundReg->control.Vin_SO2 << 7u); +} + +uint8_t NR51() { + return soundReg->control.Sound1_To_SO1 | (soundReg->control.Sound2_To_SO1 << 1) | (soundReg->control.Sound3_To_SO1 << 2) | + (soundReg->control.Sound4_To_SO1 << 3) | (soundReg->control.Sound1_To_SO2 << 4) | (soundReg->control.Sound2_To_SO2 << 5) | + (soundReg->control.Sound3_To_SO2 << 6)| (soundReg->control.Sound4_To_SO2 << 7); +} + +uint8_t NR52() { + return soundReg->control.global_On_Off << 7; +} + +//--------------------------------------------------------------------------------- +uint16_t current_value(uint8_t mode, uint8_t line) +{ + if(mode == 0) { + switch(line) + { + case 0: // global_On_Off + return soundReg->control.global_On_Off; + case 1: // Vin_SO1 + return soundReg->control.Vin_SO1; + case 2: // Vin_SO2 + return soundReg->control.Vin_SO2; + case 3: // SO1_OutputLevel + return soundReg->control.SO1_OutputLevel; + case 4: // SO2_OutputLevel + return soundReg->control.SO2_OutputLevel; + } + } else if(mode == 1) { + switch(line) + { + case 0: // sweepTime + return soundReg->mode1.sweepTime; + case 1: // sweepMode + return soundReg->mode1.sweepMode; + case 2: // sweepShifts + return soundReg->mode1.sweepShifts; + case 3: // patternDuty + return soundReg->mode1.patternDuty; + case 4: // soundLength + return soundReg->mode1.soundLength; + case 5: // envInitialValue + return soundReg->mode1.envInitialValue; + case 6: // envMode + return soundReg->mode1.envMode; + case 7: // envNbSweep + return soundReg->mode1.envNbSweep; + case 8: // frequency + case FREQUENCY: + return (soundReg->mode1.frequencyHigh << 8) | soundReg->mode1.frequencyLow; + case 9: // counter_ConsSel + return soundReg->mode1.counter_ConsSel; + case 10: // Sound1_To_SO1 + return soundReg->control.Sound1_To_SO1; + case 11: // Sound1_To_SO2 + return soundReg->control.Sound1_To_SO2; + case 12: // Sound1_On_Off + return soundReg->control.Sound1_On_Off; + } + } else if(mode == 2) { + switch(line) + { + case 0: // patternDuty + return soundReg->mode2.patternDuty; + case 1: // soundLength + return soundReg->mode2.soundLength; + case 2: // envInitialValue + return soundReg->mode2.envInitialValue; + case 3: // envMode + return soundReg->mode2.envMode; + case 4: // envNbStep + return soundReg->mode2.envNbStep; + case 5: // frequency + case FREQUENCY: + return (soundReg->mode2.frequencyHigh << 8) | soundReg->mode2.frequencyLow; + case 6: // counter_ConsSel + return soundReg->mode2.counter_ConsSel; + case 7: // Sound2_To_SO1 + return soundReg->control.Sound2_To_SO1; + case 8: // Sound2_To_SO2 + return soundReg->control.Sound2_To_SO2; + case 9: // Sound2_On_Off + return soundReg->control.Sound2_On_Off; + } + } else if(mode == 3) { + switch(line) + { + case 0: // on_Off + return soundReg->mode3.on_Off; + case 1: // soundLength + return soundReg->mode3.soundLength; + case 2: // selOutputLevel + return soundReg->mode3.selOutputLevel; + case 3: // frequency + case FREQUENCY: + return (soundReg->mode3.frequencyHigh << 8) | soundReg->mode3.frequencyLow; + case 4: // counter_ConsSel + return soundReg->mode3.counter_ConsSel; + case 5: // Sound3_To_SO1 + return soundReg->control.Sound3_To_SO1; + case 6: // Sound3_To_SO2 + return soundReg->control.Sound3_To_SO2; + case 7: // Sound3_On_Off + return soundReg->control.Sound3_On_Off; + } + } else if(mode == 4) { + switch(line) + { + case 0: // soundLength + return soundReg->mode4.soundLength; + case 1: // envInitialValue + return soundReg->mode4.envInitialValue; + case 2: // envMode + return soundReg->mode4.envMode; + case 3: // envNbStep + return soundReg->mode4.envNbStep; + case 4: // polyCounterFreq + return soundReg->mode4.polyCounterFreq; + case 5: // polyCounterStep + return soundReg->mode4.polyCounterStep; + case 6: // polyCounterDiv + return soundReg->mode4.polyCounterDiv; + case 7: // counter_ConsSel + return soundReg->mode4.counter_ConsSel; + case 8: // Sound4_To_SO1 + return soundReg->control.Sound4_To_SO1; + case 9: // Sound4_To_SO2 + return soundReg->control.Sound4_To_SO2; + case 10: // Sound4_On_Off + return soundReg->control.Sound4_On_Off; + } + } + return 0; +} + +void update_value(uint8_t mode, uint8_t line, uint16_t value) +{ + if(mode == 0) { + switch(line) + { + case 0: // global_On_Off + soundReg->control.global_On_Off = value; + NR52_REG = NR52(); + break; + case 1: // Vin_SO1 + soundReg->control.Vin_SO1 = value; + NR50_REG = NR50(); + break; + case 2: // Vin_SO2 + soundReg->control.Vin_SO2 = value; + NR50_REG = NR50(); + break; + case 3: // SO1_OutputLevel + soundReg->control.SO1_OutputLevel = value; + NR50_REG = NR50(); + break; + case 4: // SO2_OutputLevel + soundReg->control.SO2_OutputLevel = value; + NR50_REG = NR50(); + break; + case FREQUENCY: + update_value(1, FREQUENCY, value); + update_value(2, FREQUENCY, value); + update_value(3, FREQUENCY, value); + break; + case PLAY: // restart + update_value(1, FREQUENCY, current_value(1, FREQUENCY)); + update_value(2, FREQUENCY, current_value(2, FREQUENCY)); + update_value(3, FREQUENCY, current_value(3, FREQUENCY)); + soundReg->mode1.restart = value; + soundReg->mode2.restart = value; + soundReg->mode3.restart = value; + soundReg->mode4.restart = value; + NR14_REG = NR14(); + NR24_REG = NR24(); + NR34_REG = NR34(); + NR44_REG = NR44(); + soundReg->mode1.restart = 0; + soundReg->mode2.restart = 0; + soundReg->mode3.restart = 0; + soundReg->mode4.restart = 0; + break; + } + } else if(mode == 1) { + switch(line) + { + case 0: // sweepTime + soundReg->mode1.sweepTime = value; + NR10_REG = NR10(); + break; + case 1: // sweepMode + soundReg->mode1.sweepMode = value; + NR10_REG = NR10(); + break; + case 2: // sweepShifts + soundReg->mode1.sweepShifts = value; + NR10_REG = NR10(); + break; + case 3: // patternDuty + soundReg->mode1.patternDuty = value; + NR11_REG = NR11(); + break; + case 4: // soundLength + soundReg->mode1.soundLength = value; + NR11_REG = NR11(); + break; + case 5: // envInitialValue + soundReg->mode1.envInitialValue = value; + NR12_REG = NR12(); + break; + case 6: // envMode + soundReg->mode1.envMode = value; + NR12_REG = NR12(); + break; + case 7: // envNbSweep + soundReg->mode1.envNbSweep = value; + NR12_REG = NR12(); + break; + case 8: // frequency + case FREQUENCY: + soundReg->mode1.frequencyHigh = value >> 8; + soundReg->mode1.frequencyLow = 0xFF & value; + NR13_REG = NR13(); + NR14_REG = NR14(); + break; + case 9: // counter_ConsSel + soundReg->mode1.counter_ConsSel = value; + NR14_REG = NR14(); + break; + case 10: // Sound1_To_SO1 + soundReg->control.Sound1_To_SO1 = value; + NR51_REG = NR51(); + break; + case 11: // Sound1_To_SO2 + soundReg->control.Sound1_To_SO2 = value; + NR51_REG = NR51(); + break; + case 12: // Sound1_On_Off + soundReg->control.Sound1_On_Off = value; + NR52_REG = NR52(); + break; + case PLAY: // restart + update_value(mode, FREQUENCY, current_value(mode, FREQUENCY)); + soundReg->mode1.restart = value; + NR14_REG = NR14(); + soundReg->mode1.restart = 0; + break; + } + } else if(mode == 2) { + switch(line) + { + case 0: // patternDuty + soundReg->mode2.patternDuty = value; + NR21_REG = NR21(); + break; + case 1: // soundLength + soundReg->mode2.soundLength = value; + NR21_REG = NR21(); + break; + case 2: // envInitialValue + soundReg->mode2.envInitialValue = value; + NR22_REG = NR22(); + break; + case 3: // envMode + soundReg->mode2.envMode = value; + NR22_REG = NR22(); + break; + case 4: // envNbStep + soundReg->mode2.envNbStep = value; + NR22_REG = NR22(); + break; + case 5: // frequency + case FREQUENCY: + soundReg->mode2.frequencyHigh = value >> 8; + soundReg->mode2.frequencyLow = 0xFF & value; + NR23_REG = NR23(); + NR24_REG = NR24(); + break; + case 6: // counter_ConsSel + soundReg->mode2.counter_ConsSel = value; + NR24_REG = NR24(); + break; + case 7: // Sound2_To_SO1 + soundReg->control.Sound2_To_SO1 = value; + NR51_REG = NR51(); + break; + case 8: // Sound2_To_SO2 + soundReg->control.Sound2_To_SO2 = value; + NR51_REG = NR51(); + break; + case 9: // Sound2_On_Off + soundReg->control.Sound2_On_Off = value; + NR52_REG = NR52(); + break; + case PLAY: // restart + update_value(mode, FREQUENCY, current_value(mode, FREQUENCY)); + soundReg->mode2.restart = value; + NR24_REG = NR24(); + soundReg->mode2.restart = 0; + break; + } + } else if(mode == 3) { + switch(line) + { + case 0: // on_Off + soundReg->mode3.on_Off = value; + NR30_REG = NR30(); + break; + case 1: // soundLength + soundReg->mode3.soundLength = value; + NR31_REG = NR31(); + break; + case 2: // selOutputLevel + soundReg->mode3.selOutputLevel = value; + NR32_REG = NR32(); + break; + case 3: // frequency + case FREQUENCY: + soundReg->mode3.frequencyHigh = value >> 8; + soundReg->mode3.frequencyLow = 0xFF & value; + NR33_REG = NR33(); + NR34_REG = NR34(); + break; + case 4: // counter_ConsSel + soundReg->mode3.counter_ConsSel = value; + NR34_REG = NR34(); + break; + case 5: // Sound3_To_SO1 + soundReg->control.Sound3_To_SO1 = value; + NR51_REG = NR51(); + break; + case 6: // Sound3_To_SO2 + soundReg->control.Sound3_To_SO2 = value; + NR51_REG = NR51(); + break; + case 7: // Sound3_On_Off + soundReg->control.Sound3_On_Off = value; + NR52_REG = NR52(); + break; + case PLAY: // restart + update_value(mode, FREQUENCY, current_value(mode, FREQUENCY)); + soundReg->mode3.restart = value; + NR34_REG = NR34(); + soundReg->mode3.restart = 0; + break; + } + } else if(mode == 4) { + switch(line) + { + case 0: // soundLength + soundReg->mode4.soundLength = value; + NR41_REG = NR41(); + break; + case 1: // envInitialValue + soundReg->mode4.envInitialValue = value; + NR42_REG = NR42(); + break; + case 2: // envMode + soundReg->mode4.envMode = value; + NR42_REG = NR42(); + break; + case 3: // envNbStep + soundReg->mode4.envNbStep = value; + NR42_REG = NR42(); + break; + case 4: // polyCounterFreq + soundReg->mode4.polyCounterFreq = value; + NR43_REG = NR43(); + break; + case 5: // polyCounterStep + soundReg->mode4.polyCounterStep = value; + NR43_REG = NR43(); + break; + case 6: // polyCounterDiv + soundReg->mode4.polyCounterDiv = value; + NR43_REG = NR43(); + break; + case 7: // counter_ConsSel + soundReg->mode4.counter_ConsSel = value; + NR44_REG = NR44(); + break; + case 8: // Sound4_To_SO1 + soundReg->control.Sound4_To_SO1 = value; + NR51_REG = NR51(); + break; + case 9: // Sound4_To_SO2 + soundReg->control.Sound4_To_SO2 = value; + NR51_REG = NR51(); + break; + case 10: // Sound4_On_Off + soundReg->control.Sound4_On_Off = value; + NR52_REG = NR52(); + break; + case PLAY: // restart + soundReg->mode4.restart = value; + NR44_REG = NR44(); + soundReg->mode4.restart = 0; + break; + } + } +} + +uint8_t draw_screen(uint8_t mode) +{ + uint8_t i; + + clss(); + gotoxy(FIRST_X, TITLE_Y); + print(params[0].name); + + for(i = 0; params[i+1].name; i++) { + gotoxy(FIRST_X, FIRST_Y+i); + print(params[i+1].name); + gotoxy(VAL_X, FIRST_Y+i); + println(current_value(mode, i), 10, UNSIGNED); + } + + return i-1; +} + + +void play_music(uint8_t mode) +{ + uint8_t i = 0; + + while(music[i] != END) { + if(music[i] != SILENCE) { + update_value(mode, FREQUENCY, frequencies[music[i]]); + update_value(mode, PLAY, 1); + } + delay(500); + i++; + } +} + + +void show_register_channel(uint8_t mode) { + + switch (mode) { + case 1: + gotoxy(0, 16); + print("NR10-14:"); + + gotoxy(1, 17); // Last line + printn(NR10(), 16, UNSIGNED); print(", "); + printn(NR11(), 16, UNSIGNED); print(", "); + printn(NR12(), 16, UNSIGNED); print(", "); + printn(NR13(), 16, UNSIGNED); print(", "); + printn(0x80 | NR14(), 16, UNSIGNED); + + break; + + case 2: + gotoxy(0, 16); + print("NR21-24:"); + + gotoxy(1, 17); // Last line + printn(NR21(), 16, UNSIGNED); print(", "); + printn(NR22(), 16, UNSIGNED); print(", "); + printn(NR23(), 16, UNSIGNED); print(", "); + printn(0x80 | NR24(), 16, UNSIGNED); + + break; + + case 3: + gotoxy(0, 16); + print("NR30-34:"); + + gotoxy(1, 17); // Last line + printn(NR30(), 16, UNSIGNED); print(", "); + printn(NR31(), 16, UNSIGNED); print(", "); + printn(NR32(), 16, UNSIGNED); print(", "); + printn(NR33(), 16, UNSIGNED); print(", "); + printn(0x80 | NR34(), 16, UNSIGNED); + + break; + + case 4: + gotoxy(0, 16); + print("NR41-44:"); + + gotoxy(1, 17); // Last line + printn(NR41(), 16, UNSIGNED); print(", "); + printn(NR42(), 16, UNSIGNED); print(", "); + printn(NR43(), 16, UNSIGNED); print(", "); + printn(0x80 | NR44(), 16, UNSIGNED); + + break; + + case 0: + gotoxy(0, 16); + print("NR50-52:"); + + gotoxy(1, 17); // Last line + printn(NR50(), 16, UNSIGNED); print(", "); + printn(NR51(), 16, UNSIGNED); print(", "); + printn(NR52(), 16, UNSIGNED); print(", "); + + break; + + } +} + + +void dump_registers() +{ + clss(); + gotoxy(FIRST_X, TITLE_Y); + print("Register Dump\n\n"); + + print("NR10:");println(NR10(), 16, UNSIGNED); + print("NR11:");printn(NR11(), 16, UNSIGNED); print(" NR21:");println(NR21(), 16, UNSIGNED); + print("NR12:");printn(NR12(), 16, UNSIGNED); print(" NR22:");println(NR22(), 16, UNSIGNED); + print("NR13:");printn(NR13(), 16, UNSIGNED); print(" NR23:");println(NR23(), 16, UNSIGNED); + print("NR14:");printn(0x80 | NR14(), 16, UNSIGNED); print(" NR24:");println(0x80 | NR24(), 16, UNSIGNED); + printf("\n"); + + print("NR30:");println(NR30(), 16, UNSIGNED); + print("NR31:");printn(NR31(), 16, UNSIGNED); print(" NR41:");println(NR41(), 16, UNSIGNED); + print("NR32:");printn(NR32(), 16, UNSIGNED); print(" NR42:");println(NR42(), 16, UNSIGNED); + print("NR33:");printn(NR33(), 16, UNSIGNED); print(" NR43:");println(NR43(), 16, UNSIGNED); + print("NR34:");printn(0x80 | NR34(), 16, UNSIGNED); print(" NR44:");println(0x80 | NR44(), 16, UNSIGNED); + printf("\n"); + + print("NR50:");println(NR50(), 16, UNSIGNED); + print("NR51:");println(NR51(), 16, UNSIGNED); + print("NR52:");println(NR52(), 16, UNSIGNED); +} + +void wait_event(uint8_t mode) +{ + uint8_t y, last_y; + uint16_t l = 0; + uint16_t m = 0; + + while(1) { + params = params_array[mode]; + last_y = draw_screen(mode) + FIRST_Y; + y = FIRST_Y; + gotoxy(ARROW_X, y); + setchar(ARROW_CHAR); + + show_register_channel(mode); + + while(1) { + if(KEY_TICKED(J_UP)) { + gotoxy(ARROW_X, y); setchar(SPACE_CHAR); + if(--y < FIRST_Y) + y = last_y; + gotoxy(ARROW_X, y); setchar(ARROW_CHAR); + + } else if(KEY_TICKED(J_DOWN)) { + gotoxy(ARROW_X, y); setchar(SPACE_CHAR); + if(++y > last_y) + y = FIRST_Y; + gotoxy(ARROW_X, y); setchar(ARROW_CHAR); + + } else if(KEY_TICKED(J_LEFT)) { + l = current_value(mode, y-FIRST_Y); + if(l != 0) { + if(KEY_PRESSED(J_A) && KEY_PRESSED(J_B)) + l = 0; + else if(KEY_PRESSED(J_A)) + l = (l > 10) ? (l - 10) : 0; + else if(KEY_PRESSED(J_B)) + l = (l > 100) ? (l - 100) : 0; + else + l--; + update_value(mode, y-FIRST_Y, l); + } + gotoxy(VAL_X, y); print(" "); + gotoxy(VAL_X, y); println(l, 10, UNSIGNED); + + show_register_channel(mode); + + } else if(KEY_TICKED(J_RIGHT)) { + l = current_value(mode, y-FIRST_Y); + m = params[y-(FIRST_Y-1)].max; + if(l != m) { + if(KEY_PRESSED(J_A) && KEY_PRESSED(J_B)) { + l = m; + } + else if(KEY_PRESSED(J_A)) { + l += 10; + if(l > m) + l = m; + } else if(KEY_PRESSED(J_B)) { + l += 100; + if(l > m) + l = m; + } + else + l++; + update_value(mode, y-FIRST_Y, l); + } + gotoxy(VAL_X, y); print(" "); + gotoxy(VAL_X, y); println(l, 10, UNSIGNED); + + show_register_channel(mode); + + } else if(KEY_TICKED(J_START)) { + if (KEY_PRESSED(J_A)) + play_music(mode); + else + update_value(mode, PLAY, 1); + + } else if(KEY_PRESSED(J_SELECT)) { + if(KEY_PRESSED(J_A)) + dump_registers(); + else { + mode = (mode+1) % NB_MODES; + } + waitpadup(); + keys = 0; + break; + } + wait_vbl_done(); + UPDATE_KEYS(); + } + } +} + +void main() +{ + // + // Before modifying any sound register, sound must be turned on! + // (it is turned off by default to save batteries) + // + NR52_REG = 0x80; + + soundReg = &s; + NR10_REG = NR10(); + NR11_REG = NR11(); + NR12_REG = NR12(); + NR13_REG = NR13(); + NR14_REG = NR14(); + + NR21_REG = NR21(); + NR22_REG = NR22(); + NR23_REG = NR23(); + NR24_REG = NR24(); + + NR30_REG = NR30(); + NR31_REG = NR31(); + NR32_REG = NR32(); + NR33_REG = NR33(); + NR34_REG = NR34(); + + NR41_REG = NR41(); + NR42_REG = NR42(); + NR43_REG = NR43(); + NR44_REG = NR44(); + + NR50_REG = NR50(); + NR51_REG = NR51(); + NR52_REG = NR52(); + + clss(); + + wait_event(1); +} + diff --git a/gbdk-lib/examples/ap/space/Makefile b/gbdk-lib/examples/ap/space/Makefile @@ -0,0 +1,18 @@ +GBDK = ../../.. +CC = $(GBDK)/bin/lcc -mgbz80:ap -Wl-j -Wm-yS + +BINS = space.pocket + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.pocket: %.s + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/ap/space/space.s b/gbdk-lib/examples/ap/space/space.s @@ -0,0 +1,1296 @@ + ;; Little demo illustrating how to use the graphical possibilities + ;; of the GB (background, window and animated sprite) + ;; I have used fixed-point values for both the position and + ;; speed of objects to get smooth movements + ;; + ;; OBJ data : 0x8000 -> 0x8FFF (unsigned) + ;; Window data : 0x8800 -> 0x97FF (signed) + ;; Background data : 0x8800 -> 0x97FF (signed) + ;; + ;; Tiled 0xFC -> 0xFF are standard tiles (all black -> all white) + ;; + ;; Keys: + ;; Arrow keys : Change the speed (and direction) of the sprite + ;; Arrow keys + A : Change the speed (and direction) of the window + ;; Arrow keys + B : Change the speed (and direction) of the background + ;; START : Open/close the door + ;; SELECT : Basic fading effect + ;; + ;; Note that the window is kept in the lower right part of the screen + ;; since it can't be made transparent + + .include "global.s" + + .globl .init_vram + .globl .copy_vram + .globl .init_wtt + .globl .init_btt + .globl .set_xy_wtt + .globl .mv_sprite + .globl .set_sprite_prop + .globl .set_sprite_tile + .globl .jpad + + .NBDFRAMES = .endfilm-.film ; Nb frames for the door + .NBSFRAMES = 0x07 ; Nb frames for the sprite + .WINSZX = 0x80 ; Size of the picture in the window + .WINSZY = 0x50 + .MINWINX = .MAXWNDPOSX-.WINSZX+1 ; Bounds of the window origin + .MINWINY = .MAXWNDPOSY-.WINSZY+1 + .MAXWINX = .MAXWNDPOSX + .MAXWINY = .MAXWNDPOSY + .FADESTEP = 0x10 ; Nb steps for the fading effect + .STARTFADE = 0x06*.FADESTEP ; Initial value for the fading effect + + .CLOSED = 0x00 + .OPENING = 0x01 + .OPENED = 0x02 + .CLOSING = 0x03 + + .module Space + + .area _BSS + +.time: ; Global "time" value (counter) + .ds 0x01 + +.doorstate: ; State of the door (OPENED, CLOSED...) + .ds 0x01 +.doorpos: ; Current position in the door animation + .ds 0x01 + +.color: ; Current color for fading effect + .ds 0x01 + +.sframe: ; Current frame of the sprite + .ds 0x01 + +.bposx: ; Background position (fixed point) + .ds 0x02 +.bposy: + .ds 0x02 +.bspx: ; Background speed (fixed point) + .ds 0x02 +.bspy: + .ds 0x02 + +.wposx: ; Window position (fixed point) + .ds 0x02 +.wposy: + .ds 0x02 +.wspx: ; Window speed (fixed point) + .ds 0x02 +.wspy: + .ds 0x02 + +.sposx: ; Sprite position (fixed point) + .ds 0x02 +.sposy: + .ds 0x02 +.sspx: ; Sprite speed (fixed point) + .ds 0x02 +.sspy: + .ds 0x02 + + .area _CODE + +_main:: + DI ; Disable interrupts + ;; Turn the screen off + CALL .display_off + + XOR A + LD (.time),A + LD (.color),A + + LD A,#0b11100100 + LDH (.BGP),A + LDH (.OBP0),A + + ; Initialize tiles + LD HL,#0x8000 + LD DE,#0x1000 + LD B,#0x00 + CALL .init_vram ; Init the tile set at 0x8000 with 0x00 + LD B,#0xFF + CALL .init_btt ; Init the tiles tables with 0xFF + CALL .init_wtt + + LD BC,#.tp0 ; Move tiles (standard tiles) + LD HL,#0x9000-(.endtp0-.tp0) + LD DE,#.endtp0-.tp0 + CALL .copy_vram + + LD BC,#.tp1 ; Move tiles (earth) + LD HL,#0x8000 + LD DE,#.endtp1-.tp1 + CALL .copy_vram + + LD BC,#.tp2 ; Move tiles (door) + LD HL,#0x8800 + LD DE,#.endtp2-.tp2 + CALL .copy_vram + + LD BC,#.tp3 ; Move tiles (background) + LD HL,#0x9000 + LD DE,#.endtp3-.tp3 + CALL .copy_vram + + ;; Draw the background + LD BC,#.bkg_tiles + LD HL,#0x9800 + LD DE,#0x0400 ; One whole GB Screen + CALL .copy_vram + + ;; Draw the frame in the window + LD BC,#.frame_tiles + LD DE,#0x0000/8 ; Place image at (0x00,0x00) + LD HL,#0x8050/8 ; Image size is 0x80 x 0x50 + CALL .set_xy_wtt + + ;; Draw the door in the window + LD BC,#.door1_tiles + LD DE,#0x1010/8 ; Place image at (0x10,0x10) + LD HL,#0x6030/8 ; Image size is 0x60 x 0x30 + CALL .set_xy_wtt + LD A,#.CLOSED + LD (.doorstate),A + + ; Initialize background + XOR A + LD (.bposx),A + LDH (.SCX),A + LD (.bposx+1),A + LD (.bposy),A + LDH (.SCY),A + LD (.bposy+1),A + LD A,#-0x01 + LD (.bspx),A + XOR A + LD (.bspx+1),A + XOR A + LD (.bspy),A + LD A,#0x80 + LD (.bspy+1),A + + ; Initialize window + LD A,#.MAXWNDPOSX + LD (.wposx),A + LDH (.WX),A + XOR A + LD (.wposx+1),A + LD A,#.MAXWNDPOSY + LD (.wposy),A + LDH (.WY),A + XOR A + LD (.wposy+1),A + LD A,#-0x01 + LD (.wspx),A + LD A,#0x80 + LD (.wspx+1),A + LD A,#-0x01 + LD (.wspy),A + LD A,#0xC0 + LD (.wspy+1),A + + ; Initialize sprite + XOR A + LD (.sframe),A + LD C,#0x00 ; Sprite 0x00 + LD D,#0x00 ; Default sprite properties + CALL .set_sprite_prop + LD C,#0x01 ; Sprite 0x01 + LD D,#0x00 ; Default sprite properties + CALL .set_sprite_prop + + LD A,#0x10 + LD (.sposx),A + XOR A + LD (.sposx+1),A + LD A,#0x10 + LD (.sposy),A + XOR A + LD (.sposy+1),A + XOR A + LD (.sspx),A + LD A,#0x40 + LD (.sspx+1),A + XOR A + LD (.sspy),A + LD A,#0x40 + LD (.sspy+1),A + CALL .tile_sprite ; Set sprite tiles + CALL .place_sprite ; Place sprites + + LD A,#0b11100111 ; LCD = On + ; WindowBank = 0x9C00 + ; Window = On + ; BG Chr = 0x8800 + ; BG Bank = 0x9800 + ; OBJ = 8x16 + ; OBJ = On + ; BG = On + LDH (.LCDC),A + EI ; Enable interrupts +1$: + LD A,(.time) + INC A + LD (.time),A + + LD B,#0x04 ; Skip four VBLs (slow down animation) +2$: + CALL .wait_vbl_done + DEC B + JR NZ,2$ + + CALL .fade + CALL .door + CALL .scroll + CALL .animate_sprite + + CALL .jpad + LD D,A + + AND #.B ; Is B pressed ? + JP NZ,10$ + + LD A,D + AND #.A ; Is A pressed ? + JP NZ,20$ + + LD A,D + AND #.SELECT ; Is SELECT pressed ? + JR Z,3$ + LD A,#.STARTFADE + LD (.color),A +3$: + LD A,D + AND #.START ; Is START pressed ? + JR Z,5$ + LD A,(.doorstate) + CP #.CLOSED + JR NZ,4$ + LD A,#.OPENING + LD (.doorstate),A + XOR A + LD (.doorpos),A + JR 5$ +4$: + CP #.OPENED + JR NZ,5$ + LD A,#.CLOSING + LD (.doorstate),A + LD A,#.NBDFRAMES + LD (.doorpos),A +5$: + LD A,D + AND #.UP ; Is UP pressed ? + JR Z,6$ + LD BC,#0x0010 + LD A,(.sspy) ; Load speed into HL + LD H,A + LD A,(.sspy+1) + LD L,A + LD A,L ; Substract BC from HL + SUB C + LD (.sspy+1),A + LD A,H + SBC B + LD (.sspy),A ; Store new speed + JR 7$ +6$: + LD A,D + AND #.DOWN ; Is DOWN pressed ? + JR Z,7$ + LD BC,#0x0010 + LD A,(.sspy) ; Load speed into HL + LD H,A + LD A,(.sspy+1) + LD L,A + ADD HL,BC ; Add them + LD A,H ; Store new speed + LD (.sspy),A + LD A,L + LD (.sspy+1),A +7$: + LD A,D + AND #.LEFT ; Is LEFT pressed ? + JR Z,8$ + LD BC,#0x0010 + LD A,(.sspx) ; Load speed into HL + LD H,A + LD A,(.sspx+1) + LD L,A + LD A,L ; Substract BC from HL + SUB C + LD (.sspx+1),A + LD A,H + SBC B + LD (.sspx),A ; Store new speed + JP 1$ +8$: + LD A,D + AND #.RIGHT ; Is RIGHT pressed ? + JP Z,1$ + LD BC,#0x0010 + LD A,(.sspx) ; Load speed into HL + LD H,A + LD A,(.sspx+1) + LD L,A + ADD HL,BC ; Add them + LD A,H ; Store new speed + LD (.sspx),A + LD A,L + LD (.sspx+1),A + JP 1$ + +10$: + LD A,D + AND #.UP ; Is UP pressed ? + JP Z,11$ + LD BC,#0x0010 + LD A,(.bspy) ; Load speed into HL + LD H,A + LD A,(.bspy+1) + LD L,A + LD A,L ; Substract BC from HL + SUB C + LD (.bspy+1),A + LD A,H + SBC B + LD (.bspy),A ; Store new speed + JR 12$ +11$: + LD A,D + AND #.DOWN ; Is DOWN pressed ? + JP Z,12$ + LD BC,#0x0010 + LD A,(.bspy) ; Load speed into HL + LD H,A + LD A,(.bspy+1) + LD L,A + ADD HL,BC ; Add them + LD A,H ; Store new speed + LD (.bspy),A + LD A,L + LD (.bspy+1),A +12$: + LD A,D + AND #.LEFT ; Is LEFT pressed ? + JP Z,13$ + LD BC,#0x0010 + LD A,(.bspx) ; Load speed into HL + LD H,A + LD A,(.bspx+1) + LD L,A + LD A,L ; Substract BC from HL + SUB C + LD (.bspx+1),A + LD A,H + SBC B + LD (.bspx),A ; Store new speed + JP 1$ +13$: + LD A,D + AND #.RIGHT ; Is RIGHT pressed ? + JP Z,1$ + LD BC,#0x0010 + LD A,(.bspx) ; Load speed into HL + LD H,A + LD A,(.bspx+1) + LD L,A + ADD HL,BC ; Add them + LD A,H ; Store new speed + LD (.bspx),A + LD A,L + LD (.bspx+1),A + JP 1$ + +20$: + LD A,D + AND #.UP ; Is UP pressed ? + JP Z,21$ + LD BC,#0x0010 + LD A,(.wspy) ; Load speed into HL + LD H,A + LD A,(.wspy+1) + LD L,A + LD A,L ; Substract BC from HL + SUB C + LD (.wspy+1),A + LD A,H + SBC B + LD (.wspy),A ; Store new speed + JR 22$ +21$: + LD A,D + AND #.DOWN ; Is DOWN pressed ? + JP Z,22$ + LD BC,#0x0010 + LD A,(.wspy) ; Load speed into HL + LD H,A + LD A,(.wspy+1) + LD L,A + ADD HL,BC ; Add them + LD A,H ; Store new speed + LD (.wspy),A + LD A,L + LD (.wspy+1),A +22$: + LD A,D + AND #.LEFT ; Is LEFT pressed ? + JP Z,23$ + LD BC,#0x0010 + LD A,(.wspx) ; Load speed into HL + LD H,A + LD A,(.wspx+1) + LD L,A + LD A,L ; Substract BC from HL + SUB C + LD (.wspx+1),A + LD A,H + SBC B + LD (.wspx),A ; Store new speed + JP 1$ +23$: + LD A,D + AND #.RIGHT ; Is RIGHT pressed ? + JP Z,1$ + LD BC,#0x0010 + LD A,(.wspx) ; Load speed into HL + LD H,A + LD A,(.wspx+1) + LD L,A + ADD HL,BC ; Add them + LD A,H ; Store new speed + LD (.wspx),A + LD A,L + LD (.wspx+1),A + JP 1$ + + RET + + ;; Fade the screen (off and on) +.fade: + + LD A,(.color) ; Load color into A + CP #0x00 + RET Z + CP #.STARTFADE + JR NZ,1$ + LD A,#0b11111001 + JR 6$ +1$: + CP #.STARTFADE-.FADESTEP + JR NZ,2$ + LD A,#0b11111110 + JR 6$ +2$: + CP #.STARTFADE-0x02*.FADESTEP + JR NZ,3$ + LD A,#0b11111111 + JR 6$ +3$: + CP #.STARTFADE-0x03*.FADESTEP + JR NZ,4$ + LD A,#0b11111110 + JR 6$ +4$: + CP #.STARTFADE-0x04*.FADESTEP + JR NZ,5$ + LD A,#0b11111001 + JR 6$ +5$: + CP #.STARTFADE-0x05*.FADESTEP + JR NZ,7$ + LD A,#0b11100100 +6$: + LDH (.BGP),A +7$: + LD A,(.color) + DEC A + LD (.color),A + RET + + ;; Scroll the background, the window and the sprite +.scroll: + + ;; Update background + LD A,(.bposx) ; Load background position into HL + LD H,A + LD A,(.bposx+1) + LD L,A + LD A,(.bspx) ; Load background speed into BC + LD B,A + LD A,(.bspx+1) + LD C,A + ADD HL,BC ; Add them + LD A,L ; Store new background position + LD (.bposx+1),A + LD A,H + LD (.bposx),A + LDH (.SCX),A ; Update position + + LD A,(.bposy) ; Load background position into HL + LD H,A + LD A,(.bposy+1) + LD L,A + LD A,(.bspy) ; Load background speed into BC + LD B,A + LD A,(.bspy+1) + LD C,A + ADD HL,BC ; Add them + LD A,L ; Store new background position + LD (.bposy+1),A + LD A,H + LD (.bposy),A + LDH (.SCY),A ; Update position + + ;; Update window + LD A,(.wspx) ; Load window speed into BC + LD B,A + LD A,(.wspx+1) + LD C,A + LD A,(.wposx) ; Load window position into HL + LD H,A + LD A,(.wposx+1) + LD L,A + ADD HL,BC ; Add them + LD A,L ; Store new window position + LD (.wposx+1),A + LD A,H + LD (.wposx),A + + ;; X position + LD A,(.wposx) ; Check window position + LD H,#0x00 ; We must use 16 bit registers since the + LD L,A ; window is not less than 0x80 pixels + LD BC,#.MAXWINX + LD A,L ; Substract BC from HL + SUB C + LD A,H + SBC B + AND #0x80 + JR NZ,1$ ; Maximum value ? + LD A,#.MAXWINX + LD (.wposx),A ; Correct window position + LD A,(.wspx+1) ; Load window speed into BC + LD C,A + LD A,(.wspx) + LD B,A + AND #0x80 ; Speed is already negative ? + JR NZ,3$ + JR 2$ +1$: + LD A,(.wposx) ; Check window position + LD H,#0x00 ; We must use 16 bit registers since the + LD L,A ; window is not less than 0x80 pixels + LD BC,#.MINWINX+1 + LD A,L ; Substract BC from HL + SUB C + LD A,H + SBC B + AND #0x80 + JR Z,3$ ; Minimum value ? + LD A,#.MINWINX + LD (.wposx),A ; Correct window position + LD A,(.wspx+1) ; Load window speed into BC + LD C,A + LD A,(.wspx) + LD B,A + AND #0x80 ; Speed is already positive ? + JR Z,3$ +2$: + LD HL,#0x00 ; Invert speed + LD A,L ; Substract BC from HL + SUB C + LD (.wspx+1),A + LD A,H + SBC B + LD (.wspx),A ; Store new speed +3$: + LD A,(.wposx) + LDH (.WX),A ; Update position + + LD A,(.wspy) ; Load window speed into BC + LD B,A + LD A,(.wspy+1) + LD C,A + LD A,(.wposy) ; Load window position into HL + LD H,A + LD A,(.wposy+1) + LD L,A + ADD HL,BC ; Add them + LD A,L ; Store new window position + LD (.wposy+1),A + LD A,H + LD (.wposy),A + + ;; Y position + LD A,(.wposy) ; Check window position + LD H,#0x00 ; We must use 16 bit registers since the + LD L,A ; window is not less than 0x80 pixels + LD BC,#.MAXWINY + LD A,L ; Substract BC from HL + SUB C + LD A,H + SBC B + AND #0x80 + JR NZ,4$ ; Maximum value ? + LD A,#.MAXWINY + LD (.wposy),A ; Correct window position + LD A,(.wspy+1) ; Load window speed into BC + LD C,A + LD A,(.wspy) + LD B,A + AND #0x80 ; Speed is already negative ? + JR NZ,6$ + JR 5$ +4$: + LD A,(.wposy) ; Check window position + LD H,#0x00 ; We must use 16 bit registers since the + LD L,A ; window is not less than 0x80 pixels + LD BC,#.MINWINY+1 + LD A,L ; Substract BC from HL + SUB C + LD A,H + SBC B + AND #0x80 + JR Z,6$ ; Minimum value ? + LD A,#.MINWINY + LD (.wposy),A ; Correct window position + LD A,(.wspy+1) ; Load window speed into BC + LD C,A + LD A,(.wspy) + LD B,A + AND #0x80 ; Speed is already positive ? + JR Z,6$ +5$: + LD HL,#0x00 ; Invert speed + LD A,L ; Substract BC from HL + SUB C + LD (.wspy+1),A + LD A,H + SBC B + LD (.wspy),A ; Store new speed +6$: + LD A,(.wposy) + LDH (.WY),A ; Update position + + ;; Update sprite + LD A,(.sposx) ; Load sprite position into HL + LD H,A + LD A,(.sposx+1) + LD L,A + LD A,(.sspx) ; Load sprite speed into BC + LD B,A + LD A,(.sspx+1) + LD C,A + ADD HL,BC ; Add them + LD A,L ; Store new sprite position + LD (.sposx+1),A + LD A,H + LD (.sposx),A + + LD A,(.sposy) ; Load sprite position into HL + LD H,A + LD A,(.sposy+1) + LD L,A + LD A,(.sspy) ; Load sprite speed into BC + LD B,A + LD A,(.sspy+1) + LD C,A + ADD HL,BC ; Add them + LD A,L ; Store new sprite position + LD (.sposy+1),A + LD A,H + LD (.sposy),A + CALL .place_sprite ; Update position + + RET + + ;; Open and close the door +.door: + LD A,(.doorstate) + CP #.OPENING + JP Z,.open_door + CP #.CLOSING + JP Z,.close_door + RET + +.open_door: + LD A,(.doorpos) + LD HL,#.film+0x02 + LD B,#0x00 + LD C,A + ADD HL,BC + LD C,(HL) + INC HL + LD B,(HL) + LD DE,#0x1010/8 ; Place image at (0x10,0x10) + LD HL,#0x6030/8 ; Image size is 0x60 x 0x30 + CALL .set_xy_wtt + + LD A,(.doorpos) + ADD A,#0x02 + LD (.doorpos),A + CP #.NBDFRAMES + RET NZ + LD A,#.OPENED + LD (.doorstate),A + RET + +.close_door: + LD A,(.doorpos) + LD HL,#.film-0x02 + LD B,#0x00 + LD C,A + ADD HL,BC + LD C,(HL) + INC HL + LD B,(HL) + LD DE,#0x1010/8 ; Place image at (0x10,0x10) + LD HL,#0x6030/8 ; Image size is 0x60 x 0x30 + CALL .set_xy_wtt + + LD A,(.doorpos) + SUB A,#0x02 + LD (.doorpos),A + RET NZ + LD A,#.CLOSED + LD (.doorstate),A + RET + + ;; Animate sprite +.animate_sprite: + LD A,(.time) + AND #0x07 + RET NZ + + LD A,(.sframe) + INC A + CP #.NBSFRAMES + JR NZ,1$ + XOR A +1$: + LD (.sframe),A + + CALL .tile_sprite + RET + + ;; Set sprite tiles +.tile_sprite: + LD A,(.sframe) + LD HL,#.earth_tiles + RLCA + LD B,#0x00 + LD C,A + ADD HL,BC + LD C,#0x00 ; Sprite 0x00 + LD A,(HL+) + LD D,A + PUSH HL + CALL .set_sprite_tile + POP HL + + LD C,#0x01 ; Sprite 0x01 + LD A,(HL+) + LD D,A + CALL .set_sprite_tile + + RET + + ;; Place sprite +.place_sprite: + LD C,#0x00 ; Sprite 0x00 + LD A,(.sposx) + LD D,A + LD A,(.sposy) + LD E,A + PUSH DE ; Store position + CALL .mv_sprite + + LD C,#0x01 ; Sprite 0x01 + POP DE ; Restore position + LD A,#0x08 + ADD A,D + LD D,A + CALL .mv_sprite + + RET + + .area _LIT + +.tp0: + +.std_data: + + ; Basic tiles (0xFC to 0xFF) + + .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + .byte 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00 + .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + +.endtp0: + +.tp1: + +.earth_data: + + ; Tile 0x00 + .byte 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87 + .byte 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00 + .byte 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2 + .byte 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00 + .byte 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0 + .byte 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00 + .byte 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A + .byte 0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 + + ; Tile 0x08 + .byte 0x07,0x07,0x1E,0x19,0x20,0x3F,0x40,0x7F,0x42,0x7D,0x81,0xFE,0x81,0xFE,0x83,0xFC + .byte 0xD7,0xA8,0xBB,0xC4,0x6E,0x51,0x7C,0x43,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00 + .byte 0xC0,0xC0,0x70,0xB0,0xE8,0x18,0xF4,0x0C,0xF4,0x0C,0xFE,0x02,0xFE,0x02,0xFE,0x02 + .byte 0xFE,0x02,0x7E,0x82,0x3C,0xC4,0x3C,0xC4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 + .byte 0x07,0x07,0x1B,0x1C,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xE0,0x9F,0x90,0xEF,0x89,0xF6 + .byte 0x8D,0xF2,0x9F,0xE0,0x5E,0x61,0x6F,0x50,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00 + .byte 0xC0,0xC0,0xB0,0x70,0x28,0xD8,0x04,0xFC,0x2C,0xD4,0x1E,0xE2,0x1E,0xE2,0x3E,0xC2 + .byte 0x7E,0x82,0xB6,0x4A,0xE4,0x1C,0xC4,0x3C,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 + + ; Tile 0x10 + .byte 0x07,0x07,0x18,0x1F,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xEE,0x91,0xF1,0x8E,0xE0,0x9F + .byte 0xE0,0x9F,0xF1,0x8E,0x71,0x4E,0x72,0x4D,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00 + .byte 0xC0,0xC0,0xF0,0x30,0x08,0xF8,0x04,0xFC,0x04,0xFC,0x02,0xFE,0x02,0xFE,0x92,0x6E + .byte 0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 + .byte 0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1 + .byte 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00 + .byte 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2 + .byte 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 + + ; Tile 0x18 + .byte 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE + .byte 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00 + .byte 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E + .byte 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 + +.endtp1: + +.tp2: + +.frame_data: + + ; Tile 0x00 + .byte 0xFF,0x00,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F + .byte 0xFF,0x00,0x01,0xFE,0x03,0xFC,0x07,0xF8,0x0F,0xF0,0x1F,0xE0,0x3F,0xC0,0x7F,0x80 + .byte 0xFF,0x00,0xFE,0x01,0xFC,0x03,0xF8,0x07,0xF0,0x0F,0xE0,0x1F,0xC0,0x3F,0x80,0x7F + .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF + .byte 0xFF,0x00,0xFF,0x01,0xFD,0x03,0xF9,0x07,0xF1,0x0F,0xE1,0x1F,0xC1,0x3F,0x81,0x7F + .byte 0x80,0x7F,0x81,0x7E,0x83,0x7C,0x87,0x78,0x8F,0x70,0x9F,0x60,0xBF,0x40,0xFF,0x00 + .byte 0xFF,0x70,0xFF,0x98,0xEF,0xB8,0xCF,0xF8,0xFF,0x70,0xFF,0x00,0xFF,0x00,0xFF,0x01 + .byte 0xFF,0x00,0xFE,0x01,0xFC,0x03,0xF8,0x07,0xF0,0x0F,0xE0,0x1F,0xC0,0x3F,0xFF,0xFF + + ; Tile 0x08 + .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF + .byte 0x00,0xFF,0x01,0xFE,0x03,0xFC,0x07,0xF8,0x0F,0xF0,0x1F,0xE0,0x3F,0xC0,0xFF,0xFF + .byte 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF + .byte 0xFF,0x0E,0xFF,0x13,0xFD,0x17,0xF9,0x1F,0xFE,0x0F,0xE0,0x1F,0xC0,0x3F,0x80,0xFF + .byte 0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF + .byte 0xFF,0x01,0xFF,0x01,0xFD,0x03,0xF9,0x07,0xF1,0x0F,0xE1,0x1F,0xC1,0x3F,0x81,0x7F + .byte 0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F + .byte 0x01,0xFF,0x01,0xFF,0x03,0xFD,0x07,0xF9,0x0F,0xF1,0x1F,0xE1,0x3F,0xC1,0x7F,0x81 + + ; Tile 0x10 + .byte 0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01 + .byte 0x01,0xFF,0x01,0xFE,0x03,0xFC,0x77,0xF8,0xFF,0x98,0xEF,0xB8,0xCF,0xF8,0x7F,0xF0 + .byte 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x0E,0xFF,0x13,0xFD,0x17,0xF9,0x1F,0xFF,0x0E + .byte 0x80,0x7F,0x81,0x7E,0x83,0x7C,0x87,0x78,0x8F,0x70,0x9F,0x60,0xBF,0x40,0xFF,0x7F + .byte 0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0xFF,0xFF + +.door1_data: + + ; Tile 0x15 + .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF + .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF + .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF + +.door2_data: + + ; Tile 0x18 + .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF + .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF + .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF + .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + +.door3_data: + + ; Tile 0x1C + .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF + .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF + .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF + .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + +.door4_data: + + ; Tile 0x20 + .byte 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + +.endtp2: + +.tp3: + +.bkg_data: + + ; Tile 0x00 + .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0xFF,0xFF,0xFF,0xFF + .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0xFF,0xFF,0xFF + .byte 0xFF,0xFF,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,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; Tile 0x28 + .byte 0xF7,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF + .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + .byte 0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + +.endtp3: + + ; Image size: 0x40 x 0x40 + ; Number of tiles (total - unique): 0x40 - 0x2D + +.bkg_tiles: + + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC + + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A + + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC + + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14 + + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC + + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20 + + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26 + + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11 + + ; Image size: 0x10 x 0x70 + ; Number of tiles (total - unique): 0x1C - 0x1C + +.earth_tiles: + + .byte 0x00,0x02 + .byte 0x04,0x06 + .byte 0x08,0x0A + .byte 0x0C,0x0E + .byte 0x10,0x12 + .byte 0x14,0x16 + .byte 0x18,0x1A + + ; Image size: 0x80 x 0x50 + ; Number of tiles (total - unique): 0xA0 - 0x15 + +.frame_tiles: + + .byte 0x80,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x84 + .byte 0x85,0x86,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x8B,0x8C + .byte 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F + .byte 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90 + .byte 0x8E,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0x8D + .byte 0x85,0x90,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x82,0x8C + .byte 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F + .byte 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90 + .byte 0x8E,0x91,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0x92,0x8D + .byte 0x93,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x94 + + ; Image size: 0x60 x 0x30 + ; Number of tiles (total - unique): 0x48 - 0x03 + +.door1_tiles: + + .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95 + .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96 + .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97 + .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95 + .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96 + .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97 + + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + + ; Image size: 0x60 x 0x30 + ; Number of tiles (total - unique): 0x48 - 0x04 + +.door2_tiles: + + .byte 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98 + .byte 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99 + .byte 0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A + .byte 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98 + .byte 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99 + .byte 0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B + + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + + ; Image size: 0x60 x 0x30 + ; Number of tiles (total - unique): 0x48 - 0x04 + +.door3_tiles: + + .byte 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C + .byte 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D + .byte 0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E + .byte 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C + .byte 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D + .byte 0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F + + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + + ; Image size: 0x60 x 0x30 + ; Number of tiles (total - unique): 0x48 - 0x01 + +.door4_tiles: + + .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95 + .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96 + .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97 + .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95 + .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96 + .byte 0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0 + + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC + +.film: + .word .door1_tiles+0x0C*0 + .word .door2_tiles+0x0C*0 + .word .door3_tiles+0x0C*0 + .word .door4_tiles+0x0C*0 + .word .door1_tiles+0x0C*1 + .word .door2_tiles+0x0C*1 + .word .door3_tiles+0x0C*1 + .word .door4_tiles+0x0C*1 + .word .door1_tiles+0x0C*2 + .word .door2_tiles+0x0C*2 + .word .door3_tiles+0x0C*2 + .word .door4_tiles+0x0C*2 + .word .door1_tiles+0x0C*3 + .word .door2_tiles+0x0C*3 + .word .door3_tiles+0x0C*3 + .word .door4_tiles+0x0C*3 + .word .door1_tiles+0x0C*4 + .word .door2_tiles+0x0C*4 + .word .door3_tiles+0x0C*4 + .word .door4_tiles+0x0C*4 + .word .door1_tiles+0x0C*5 + .word .door2_tiles+0x0C*5 + .word .door3_tiles+0x0C*5 + .word .door4_tiles+0x0C*5 +.endfilm: + .word .door1_tiles+0x0C*6 diff --git a/gbdk-lib/examples/ap/template_minimal/Makefile b/gbdk-lib/examples/ap/template_minimal/Makefile @@ -0,0 +1,33 @@ +# +# Simple Makefile that compiles all .c and .s files in the same folder +# + +# If you move this project you can change the directory +# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" +GBDK_HOME = ../../../ + +LCC = $(GBDK_HOME)bin/lcc -mgbz80:ap + +# You can uncomment the line below to turn on debug output +# LCC = $(LCC) -debug + +# You can set the name of the .pocket ROM file here +PROJECTNAME = Example + +BINS = $(PROJECTNAME).pocket +CSOURCES := $(wildcard *.c) +ASMSOURCES := $(wildcard *.s) + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link all source files in a single call to LCC +$(BINS): $(CSOURCES) $(ASMSOURCES) + $(LCC) -o $@ $(CSOURCES) $(ASMSOURCES) + +clean: + rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm + diff --git a/gbdk-lib/examples/ap/template_minimal/Readme.md b/gbdk-lib/examples/ap/template_minimal/Readme.md @@ -0,0 +1,7 @@ + +An minimal template project with a Makefile that only compiles files in the same directory + +The Makefile will automatically detect and compile new source files as long +as they are placed in the same directory as the Makefile + + diff --git a/gbdk-lib/examples/ap/template_minimal/main.c b/gbdk-lib/examples/ap/template_minimal/main.c @@ -0,0 +1,17 @@ +#include <gb/gb.h> +#include <stdint.h> + + +void main(void) +{ + // Loop forever + while(1) { + + + // Game main loop processing goes here + + + // Done processing, yield CPU and wait for start of next frame + wait_vbl_done(); + } +} diff --git a/gbdk-lib/examples/ap/template_subfolders/Makefile b/gbdk-lib/examples/ap/template_subfolders/Makefile @@ -0,0 +1,61 @@ +# +# A Makefile that compiles all .c and .s files in "src" and "res" +# subdirectories and places the output in a "obj" subdirectory +# + +# If you move this project you can change the directory +# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" +GBDK_HOME = ../../../ + +LCC = $(GBDK_HOME)bin/lcc + +LCCFLAGS = -mgbz80:ap +# You can set flags for LCC here +# For example, you can uncomment the line below to turn on debug output +# LCCFLAGS += -debug + +# You can set the name of the .pocket ROM file here +PROJECTNAME = Example + +SRCDIR = src +OBJDIR = obj +RESDIR = res +BINS = $(OBJDIR)/$(PROJECTNAME).pocket +CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c))) +ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s))) +OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o) + +all: prepare $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile .c files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.c + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# Compile .c files in "res/" to .o object files +$(OBJDIR)/%.o: $(RESDIR)/%.c + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# Compile .s assembly files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.s + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# If needed, compile .c files i n"src/" to .s assembly files +# (not required if .c is compiled directly to .o) +$(OBJDIR)/%.s: $(SRCDIR)/%.c + $(LCC) $(LCCFLAGS) -S -o $@ $< + +# Link the compiled object files into a .pocket ROM file +$(BINS): $(OBJS) + $(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS) + +prepare: + mkdir -p $(OBJDIR) + +clean: +# rm -f *.pocket *.ihx *.cdb *.adb *.noi *.map + rm -f $(OBJDIR)/*.* + diff --git a/gbdk-lib/examples/ap/template_subfolders/Readme.md b/gbdk-lib/examples/ap/template_subfolders/Readme.md @@ -0,0 +1,18 @@ + +A template project with a Makefile that supports sub-directories. + +The Makefile will automatically detect and compile new source files +when they are added to the "src" and "res" directories. + +Project directories + - src: Main program source files (.c, .h, .s) can go here + - res: Program graphics and audio source files (.c, .h, .s) can go here + - obj: Compiled ROM (.gb) and debug files go in this directory + + +== Sprite and Background tiles from: == + +https://sondanielson.itch.io/gameboy-simple-rpg-tileset +"Licence is under CCA so you can use these assets both privately and commercially" +"You are free to use them as is or modify them to your liking. All i ask is you credit me if you do use them please :)" + diff --git a/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbm b/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbm Binary files differ. diff --git a/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbr b/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbr Binary files differ. diff --git a/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.c b/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.c @@ -0,0 +1,133 @@ +/* + + DUNGEON_MAP.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 32 x 32 + Tile set : dungeon_32x32.gbr + Plane count : 1 plane (8 bits) + Plane order : Planes are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define dungeon_mapWidth 32 +#define dungeon_mapHeight 32 +#define dungeon_mapBank 0 + +#define dungeon_map dungeon_mapPLN0 +const unsigned char dungeon_mapPLN0[] = +{ + 0x0A,0x0B,0x07,0x05,0x06,0x04,0x07,0x03,0x04,0x07, + 0x03,0x04,0x07,0x08,0x09,0x01,0x0A,0x0B,0x07,0x07, + 0x03,0x04,0x07,0x03,0x04,0x07,0x03,0x04,0x03,0x0C, + 0x08,0x09,0x0D,0x0E,0x0F,0x12,0x13,0x11,0x0F,0x10, + 0x11,0x0F,0x10,0x11,0x0F,0x14,0x15,0x01,0x0D,0x0E, + 0x0F,0x0F,0x10,0x11,0x0F,0x10,0x11,0x0F,0x10,0x11, + 0x10,0x16,0x14,0x15,0x17,0x18,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01, + 0x1B,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x1D,0x1E,0x1F,0x1C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19, + 0x1A,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x21,0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22, + 0x1F,0x1C,0x00,0x00,0x00,0x23,0x24,0x25,0x24,0x26, + 0x00,0x00,0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00, + 0x00,0x23,0x24,0x25,0x24,0x26,0x00,0x00,0x00,0x00, + 0x27,0x28,0x17,0x18,0x00,0x00,0x00,0x19,0x2B,0x2C, + 0x2D,0x20,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x19,0x2B,0x2C,0x2D,0x20,0x00,0x00, + 0x00,0x00,0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x21, + 0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x21,0x15,0x01, + 0x0D,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x00,0x21,0x22,0x1B,0x20,0x00,0x00, + 0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x30, + 0x31,0x32,0x33,0x20,0x00,0x00,0x00,0x21,0x22,0x01, + 0x1F,0x1C,0x00,0x00,0x00,0x00,0x19,0x1A,0x1F,0x1C, + 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00, + 0x00,0x34,0x35,0x0F,0x10,0x36,0x00,0x00,0x00,0x27, + 0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x00,0x21,0x22, + 0x1F,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00, + 0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x19,0x1A,0x01, + 0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20,0x00,0x00, + 0x00,0x00,0x21,0x22,0x1B,0x20,0x00,0x00,0x00,0x21, + 0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x00,0x27,0x28,0x1F,0x1C,0x00,0x00, + 0x00,0x19,0x1A,0x01,0x37,0x38,0x24,0x26,0x00,0x00, + 0x00,0x23,0x24,0x24,0x25,0x24,0x39,0x3A,0x3B,0x01, + 0x1F,0x1C,0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20, + 0x00,0x00,0x00,0x21,0x22,0x01,0x3C,0x3D,0x2D,0x20, + 0x00,0x00,0x00,0x19,0x2B,0x3E,0x3F,0x3E,0x40,0x41, + 0x42,0x01,0x1B,0x20,0x00,0x00,0x00,0x00,0x21,0x22, + 0x1F,0x1C,0x00,0x00,0x00,0x27,0x15,0x01,0x01,0x01, + 0x1F,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x0D,0x20,0x00,0x00,0x00,0x00, + 0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x30,0x31,0x0B, + 0x03,0x07,0x33,0x20,0x00,0x00,0x00,0x30,0x31,0x08, + 0x09,0x01,0x0A,0x0B,0x07,0x0B,0x33,0x20,0x00,0x00, + 0x00,0x00,0x21,0x22,0x1F,0x1C,0x00,0x00,0x00,0x34, + 0x35,0x0F,0x10,0x0F,0x10,0x36,0x00,0x00,0x00,0x34, + 0x35,0x14,0x15,0x01,0x0D,0x0E,0x0F,0x0F,0x10,0x36, + 0x00,0x00,0x00,0x00,0x19,0x22,0x29,0x2A,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x44,0x2E,0x2F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x45,0x46, + 0x1B,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x31,0x32, + 0x33,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x21,0x22,0x37,0x38,0x24,0x24,0x24,0x24,0x24,0x25, + 0x24,0x39,0x24,0x25,0x24,0x26,0x00,0x00,0x00,0x34, + 0x35,0x0F,0x10,0x36,0x00,0x00,0x00,0x23,0x24,0x24, + 0x24,0x24,0x3A,0x3B,0x3C,0x3D,0x3E,0x3E,0x3E,0x3E, + 0x3E,0x3F,0x3E,0x40,0x3E,0x2C,0x2D,0x20,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19, + 0x2B,0x41,0x3E,0x3E,0x41,0x42,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x21,0x22,0x01,0x01,0x01,0x01,0x01,0x0A,0x0B, + 0x07,0x03,0x07,0x03,0x04,0x07,0x03,0x04,0x0B,0x0B, + 0x33,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x30,0x31,0x0B,0x07,0x03,0x08,0x09, + 0x0D,0x0E,0x0F,0x10,0x0F,0x10,0x11,0x0F,0x10,0x11, + 0x10,0x0F,0x10,0x36,0x00,0x00,0x00,0x23,0x24,0x25, + 0x24,0x26,0x00,0x00,0x00,0x34,0x35,0x10,0x0F,0x10, + 0x14,0x15,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19, + 0x2B,0x2C,0x2D,0x20,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x27,0x28,0x1F,0x1C,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22,0x47,0x48, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22, + 0x37,0x38,0x49,0x4A,0x4B,0x24,0x39,0x24,0x24,0x24, + 0x25,0x24,0x39,0x24,0x24,0x39,0x25,0x3A,0x3B,0x01, + 0x37,0x38,0x24,0x25,0x24,0x39,0x24,0x25,0x24,0x39, + 0x3A,0x3B,0x3C,0x3D,0x4C,0x4D,0x4E,0x3E,0x40,0x3E, + 0x3E,0x3E,0x3F,0x3E,0x40,0x3E,0x3E,0x40,0x3F,0x41, + 0x42,0x01,0x3C,0x3D,0x3E,0x3F,0x3E,0x40,0x3E,0x3F, + 0x3E,0x40,0x41,0x42 +}; + +/* End of DUNGEON_MAP.C */ diff --git a/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.h b/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.h @@ -0,0 +1,28 @@ +/* + + DUNGEON_MAP.H + + Map Include File. + + Info: + Section : + Bank : 0 + Map size : 32 x 32 + Tile set : dungeon_32x32.gbr + Plane count : 1 plane (8 bits) + Plane order : Planes are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define dungeon_mapWidth 32 +#define dungeon_mapHeight 32 +#define dungeon_mapBank 0 + +#define dungeon_map dungeon_mapPLN0 +extern const unsigned char dungeon_mapPLN0[]; + +/* End of DUNGEON_MAP.H */ diff --git a/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.c b/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.c @@ -0,0 +1,188 @@ +/* + + DUNGEON_TILES.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 78 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + +/* Start of tile array. */ +const unsigned char dungeon_tiles[] = +{ + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0x08,0x08,0x08,0x08,0xEB,0x1C, + 0xFF,0xFF,0x80,0x80,0xFF,0x80,0xFF,0x80, + 0xFF,0xFF,0x10,0x10,0x10,0x10,0xD7,0x38, + 0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0xFF,0x78,0x37,0xF3,0x6F,0x67,0xDF, + 0xCF,0xFF,0x4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3,0xFD, + 0xC7,0xFB,0x0F,0xF7,0xFF,0xFD,0xD5,0x19, + 0x9B,0x88,0x9B,0x88,0x9B,0x88,0x8B,0x98, + 0xFB,0xF8,0x8B,0x98,0x9B,0x88,0xFF,0xFF, + 0x71,0xEF,0x31,0xEF,0x33,0xEF,0x3F,0xFF, + 0x31,0xEF,0x31,0xEF,0x73,0xEF,0xFF,0xFF, + 0xFF,0xFF,0xCE,0xFF,0x84,0xFF,0x84,0xFF, + 0xFF,0x84,0xFF,0xFF,0xC3,0xFF,0x81,0xFF, + 0xE0,0xDF,0x5F,0xFF,0xDA,0x7F,0xD5,0x7F, + 0x5F,0x7F,0xDA,0xFF,0x5F,0xFF,0xDF,0x7F, + 0x07,0xFB,0xFA,0xFF,0xAB,0xFE,0x5B,0xFE, + 0xFA,0xFE,0xAB,0xFF,0xFA,0xFF,0xFB,0xFE, + 0xFF,0x81,0xFF,0x81,0x81,0x81,0xFF,0xFF, + 0xD7,0xB8,0x90,0x90,0x90,0x90,0xFF,0xFF, + 0xDF,0x7F,0xDF,0x7F,0x4F,0x7F,0xCF,0xFF, + 0x67,0xDF,0xF3,0x6F,0x78,0x37,0xFF,0xFF, + 0xFB,0xFE,0xFB,0xFE,0xF2,0xFE,0xF3,0xFF, + 0xE6,0xFB,0xCF,0xF6,0x1E,0xEC,0xFF,0xFF +}; + +/* End of DUNGEON_TILES.C */ diff --git a/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.h b/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.h @@ -0,0 +1,103 @@ +/* + + DUNGEON_TILES.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 78 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + + +/* Bank of tiles. */ +#define dungeon_tilesBank 0 + +/* Super Gameboy palette 0 */ +#define dungeon_tilesSGBPal0c0 0 +#define dungeon_tilesSGBPal0c1 0 +#define dungeon_tilesSGBPal0c2 22528 +#define dungeon_tilesSGBPal0c3 44 + +/* Super Gameboy palette 1 */ +#define dungeon_tilesSGBPal1c0 6076 +#define dungeon_tilesSGBPal1c1 8935 +#define dungeon_tilesSGBPal1c2 6596 +#define dungeon_tilesSGBPal1c3 5344 + +/* Super Gameboy palette 2 */ +#define dungeon_tilesSGBPal2c0 6076 +#define dungeon_tilesSGBPal2c1 8935 +#define dungeon_tilesSGBPal2c2 6596 +#define dungeon_tilesSGBPal2c3 5344 + +/* Super Gameboy palette 3 */ +#define dungeon_tilesSGBPal3c0 6076 +#define dungeon_tilesSGBPal3c1 8935 +#define dungeon_tilesSGBPal3c2 6596 +#define dungeon_tilesSGBPal3c3 5344 + +/* Gameboy Color palette 0 */ +#define dungeon_tilesCGBPal0c0 26620 +#define dungeon_tilesCGBPal0c1 14096 +#define dungeon_tilesCGBPal0c2 10662 +#define dungeon_tilesCGBPal0c3 2112 + +/* Gameboy Color palette 1 */ +#define dungeon_tilesCGBPal1c0 6076 +#define dungeon_tilesCGBPal1c1 8935 +#define dungeon_tilesCGBPal1c2 6596 +#define dungeon_tilesCGBPal1c3 5344 + +/* Gameboy Color palette 2 */ +#define dungeon_tilesCGBPal2c0 6076 +#define dungeon_tilesCGBPal2c1 8935 +#define dungeon_tilesCGBPal2c2 6596 +#define dungeon_tilesCGBPal2c3 5344 + +/* Gameboy Color palette 3 */ +#define dungeon_tilesCGBPal3c0 6076 +#define dungeon_tilesCGBPal3c1 8935 +#define dungeon_tilesCGBPal3c2 6596 +#define dungeon_tilesCGBPal3c3 5344 + +/* Gameboy Color palette 4 */ +#define dungeon_tilesCGBPal4c0 6076 +#define dungeon_tilesCGBPal4c1 8935 +#define dungeon_tilesCGBPal4c2 6596 +#define dungeon_tilesCGBPal4c3 5344 + +/* Gameboy Color palette 5 */ +#define dungeon_tilesCGBPal5c0 6076 +#define dungeon_tilesCGBPal5c1 8935 +#define dungeon_tilesCGBPal5c2 6596 +#define dungeon_tilesCGBPal5c3 5344 + +/* Gameboy Color palette 6 */ +#define dungeon_tilesCGBPal6c0 6076 +#define dungeon_tilesCGBPal6c1 8935 +#define dungeon_tilesCGBPal6c2 6596 +#define dungeon_tilesCGBPal6c3 5344 + +/* Gameboy Color palette 7 */ +#define dungeon_tilesCGBPal7c0 6076 +#define dungeon_tilesCGBPal7c1 8935 +#define dungeon_tilesCGBPal7c2 6596 +#define dungeon_tilesCGBPal7c3 5344 +/* Start of tile array. */ +extern const const unsigned char dungeon_tiles[]; + +/* End of DUNGEON_TILES.H */ diff --git a/gbdk-lib/examples/ap/template_subfolders/src/main.c b/gbdk-lib/examples/ap/template_subfolders/src/main.c @@ -0,0 +1,31 @@ +#include <gb/gb.h> +#include <stdint.h> +#include "../res/dungeon_map.h" +#include "../res/dungeon_tiles.h" + + +void init_gfx() { + // Load Background tiles and then map + set_bkg_data(0, 79u, dungeon_tiles); + set_bkg_tiles(0, 0, 32u, 32u, dungeon_mapPLN0); + + // Turn the background map on to make it visible + SHOW_BKG; +} + + +void main(void) +{ + init_gfx(); + + // Loop forever + while(1) { + + + // Game main loop processing goes here + + + // Done processing, yield CPU and wait for start of next frame + wait_vbl_done(); + } +} diff --git a/gbdk-lib/examples/gb/fprpn/Makefile b/gbdk-lib/examples/broken/fprpn/Makefile diff --git a/gbdk-lib/examples/gb/fprpn/fprpn.c b/gbdk-lib/examples/broken/fprpn/fprpn.c diff --git a/gbdk-lib/examples/gb/dscan/Makefile b/gbdk-lib/examples/gb/dscan/Makefile @@ -1,4 +1,4 @@ -CC = ../../../bin/lcc -Wa-l -Wl-m +CC = ../../../bin/lcc -Wm-yc BINS = dscan.gb @@ -22,7 +22,3 @@ make.bat: Makefile clean: rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm - -# Link file, and write 0x80 at position 0x143 in header -dscan.gb: dscan.o - $(CC) -Wm-yc -o dscan.gb dscan.o diff --git a/gbdk-lib/examples/gb/lcd_isr_wobble/lcd_isr_wobble.c b/gbdk-lib/examples/gb/lcd_isr_wobble/lcd_isr_wobble.c @@ -16,7 +16,7 @@ void main() { printf("This is\na wobble\ntest\nfor DMG\n|\n|\n|\n|\n|"); CRITICAL { - STAT_REG = 0x18; + STAT_REG = STATF_MODE01 | STATF_MODE00; add_LCD(scanline_isr); } set_interrupts(VBL_IFLAG | LCD_IFLAG); diff --git a/gbdk-lib/examples/gb/scroller/text_scroller.c b/gbdk-lib/examples/gb/scroller/text_scroller.c @@ -42,7 +42,7 @@ void main() { printf("Scrolling %d chars", sizeof(scroller_text) - 1); CRITICAL { - STAT_REG |= 0b01000000; LYC_REG = 0; + STAT_REG |= STATF_LYC; LYC_REG = 0; add_LCD(scanline_isr); set_interrupts(VBL_IFLAG | LCD_IFLAG); } diff --git a/gbdk-lib/examples/gb/simple_physics/Makefile b/gbdk-lib/examples/gb/simple_physics/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -Wl-m -Wl-j -Wm-yS + +BINS = phys.gb + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass +%.gb: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/gb/simple_physics/phys.c b/gbdk-lib/examples/gb/simple_physics/phys.c @@ -0,0 +1,88 @@ +#include <gb/gb.h> +#include <gb/sgb.h> + +#include <stdio.h> +#include <gb/console.h> + +UINT8 sprite_data[] = { + 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0xA9,0xFF,0x89,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0xB9,0xFF,0x89,0xFF,0x91,0xFF,0xB9,0xFF,0x42,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0x89,0xFF,0x99,0xFF,0x89,0xFF,0x5A,0x7E,0x3C,0x3C, + 0x3C,0x3C,0x42,0x7E,0xA9,0xFF,0xA9,0xFF,0xB9,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C + +}; + +joypads_t joypads; + +// sprite coords +UINT16 PosX, PosY; +INT16 SpdX, SpdY; +UINT8 Jump; + +// main funxction +void main(void) { + // init palettes + BGP_REG = OBP0_REG = OBP1_REG = 0xE4; + + // load tile data into VRAM + set_sprite_data(0, 4, sprite_data); + + // set sprite tile + set_sprite_tile(0, 0); + + // show bkg and sprites + SHOW_BKG; SHOW_SPRITES; + + // init 2 joypads + joypad_init(1, &joypads); + + PosX = PosY = 64 << 4; + Jump = SpdX = SpdY = 0; + + while(1) { + // poll joypads + joypad_ex(&joypads); + + // game object + if (joypads.joy0 & J_UP) { + SpdY -= 2; + if (SpdY < -64) SpdY = -64; + } else if (joypads.joy0 & J_DOWN) { + SpdY += 2; + if (SpdY > 64) SpdY = 64; + } + if (joypads.joy0 & J_LEFT) { + SpdX -= 2; + if (SpdX < -64) SpdX = -64; + } else if (joypads.joy0 & J_RIGHT) { + SpdX += 2; + if (SpdX > 64) SpdX = 64; + } + if ((joypads.joy0 & J_A) && (!Jump)) { + Jump = 3; + } + + // jump + if (Jump) { + SpdY -= 8; + if (SpdY < -32) SpdY = -32; + Jump--; + } + + PosX += SpdX, PosY += SpdY; + + // translate to pixels and move sprite + move_sprite(0, PosX >> 4, PosY >> 4); + + // decelerate + if (SpdY >= 0) { + if (SpdY) SpdY--; + } else SpdY ++; + if (SpdX >= 0) { + if (SpdX) SpdX--; + } else SpdX ++; + + // wait for VBlank to slow down everything + wait_vbl_done(); + } +} + diff --git a/gbdk-lib/examples/gg/Makefile b/gbdk-lib/examples/gg/Makefile @@ -0,0 +1,17 @@ +# Register all subdirectories in the project's root directory. +SUBDIRS := $(wildcard */.) + +# Top-level phony targets. +all clean make.bat: $(SUBDIRS) FORCE +# Similar to: +# .PHONY: all clean +# all clean: $(SUBDIRS) +# GNU's .PHONY target is more efficient in that it explicitly declares non-files. + +# Recurse `make` into each subdirectory +# Pass along targets specified at command-line (if any). +$(SUBDIRS): FORCE + $(MAKE) -C $@ $(MAKECMDGOALS) + +# Force targets. +FORCE: + diff --git a/gbdk-lib/examples/gg/smoke/Makefile b/gbdk-lib/examples/gg/smoke/Makefile @@ -0,0 +1,30 @@ +CC = ../../../bin/lcc -mz80:gg -Wm-yoA -Wa-l -Wl-m -Wl-j + +BINS = smoketest.gg + +all: $(BINS) + +ASRC = $(wildcard *.s) +CSRC = $(wildcard *.c) + +OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass + +%.o: %.c + $(CC) -c -o $@ $< + +%.o: %.s + $(CC) -c -o $@ $< + +$(BINS): $(OBJS) + $(CC) -Wm-yS -o $@ $^ + rm -f *.map *.noi *.ihx *.lst + +clean: + rm -f *.o *.lst *.map *.gg *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/gg/smoke/assets.c b/gbdk-lib/examples/gg/smoke/assets.c @@ -0,0 +1,46 @@ +#pragma bank 2 + +#include <sms/sms.h> + +BANKREF(earth_data) +const unsigned char earth_data[] = { + + /* Tile 0x00 */ + 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87, + 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2, + 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0, + 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A, + 0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x08 */ + 0x07,0x07,0x1E,0x19,0x20,0x3F,0x40,0x7F,0x42,0x7D,0x81,0xFE,0x81,0xFE,0x83,0xFC, + 0xD7,0xA8,0xBB,0xC4,0x6E,0x51,0x7C,0x43,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0xE8,0x18,0xF4,0x0C,0xF4,0x0C,0xFE,0x02,0xFE,0x02,0xFE,0x02, + 0xFE,0x02,0x7E,0x82,0x3C,0xC4,0x3C,0xC4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1B,0x1C,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xE0,0x9F,0x90,0xEF,0x89,0xF6, + 0x8D,0xF2,0x9F,0xE0,0x5E,0x61,0x6F,0x50,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xB0,0x70,0x28,0xD8,0x04,0xFC,0x2C,0xD4,0x1E,0xE2,0x1E,0xE2,0x3E,0xC2, + 0x7E,0x82,0xB6,0x4A,0xE4,0x1C,0xC4,0x3C,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x10 */ + 0x07,0x07,0x18,0x1F,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xEE,0x91,0xF1,0x8E,0xE0,0x9F, + 0xE0,0x9F,0xF1,0x8E,0x71,0x4E,0x72,0x4D,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xF0,0x30,0x08,0xF8,0x04,0xFC,0x04,0xFC,0x02,0xFE,0x02,0xFE,0x92,0x6E, + 0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1, + 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2, + 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x18 */ + 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE, + 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E, + 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 +}; + +BANKREF(earth_data_size) +const unsigned int earth_data_size = sizeof(earth_data); diff --git a/gbdk-lib/examples/gg/smoke/banked.c b/gbdk-lib/examples/gg/smoke/banked.c @@ -0,0 +1,7 @@ +#pragma bank 3 + +#include <stdint.h> + +uint16_t banked_func(uint8_t be, uint8_t ef) __banked { + return ((be << 8) | ef); +} + diff --git a/gbdk-lib/examples/gg/smoke/smoketest.c b/gbdk-lib/examples/gg/smoke/smoketest.c @@ -0,0 +1,55 @@ +#include <sms/sms.h> + +BANKREF_EXTERN(earth_data) +extern const unsigned char earth_data[]; + +BANKREF_EXTERN(earth_data_size) +extern const unsigned int earth_data_size; + +const uint8_t tilemap[] = {2, 4, 6, 8, 3, 5, 7, 9}; + +uint16_t banked_func(uint8_t be, uint8_t ef) __banked; + +joypads_t joy; +void main() { + DISPLAY_ON; + +// vmemcpy(0x4000, earth_data, sizeof(earth_data)); + + SWITCH_ROM(BANK(earth_data)); + if (banked_func(0xBE, 0xEF) == 0xBEEF) { + set_bkg_2bpp_data(2, earth_data_size >> 4, earth_data); + } + + set_bkg_tiles(4, 10, 4, 2, tilemap); + + joypad_init(2, &joy); + + while(TRUE) { + joypad_ex(&joy); + + if (joy.joy0 & J_LEFT) { + scroll_bkg(-1, 0); + } else if (joy.joy0 & J_RIGHT) { + scroll_bkg(1, 0); + } + if (joy.joy0 & J_UP) { + scroll_bkg(0, -1); + } else if (joy.joy0 & J_DOWN) { + scroll_bkg(0, 1); + } + + if (joy.joy1 & J_LEFT) { + scroll_bkg(-1, 0); + } else if (joy.joy1 & J_RIGHT) { + scroll_bkg(1, 0); + } + if (joy.joy1 & J_UP) { + scroll_bkg(0, -1); + } else if (joy.joy1 & J_DOWN) { + scroll_bkg(0, 1); + } + + wait_vbl_done(); + } +} diff --git a/gbdk-lib/examples/sms/Makefile b/gbdk-lib/examples/sms/Makefile @@ -0,0 +1,17 @@ +# Register all subdirectories in the project's root directory. +SUBDIRS := $(wildcard */.) + +# Top-level phony targets. +all clean make.bat: $(SUBDIRS) FORCE +# Similar to: +# .PHONY: all clean +# all clean: $(SUBDIRS) +# GNU's .PHONY target is more efficient in that it explicitly declares non-files. + +# Recurse `make` into each subdirectory +# Pass along targets specified at command-line (if any). +$(SUBDIRS): FORCE + $(MAKE) -C $@ $(MAKECMDGOALS) + +# Force targets. +FORCE: + diff --git a/gbdk-lib/examples/sms/smoke/Makefile b/gbdk-lib/examples/sms/smoke/Makefile @@ -0,0 +1,30 @@ +CC = ../../../bin/lcc -mz80:sms -Wm-yoA -Wa-l -Wl-j + +BINS = smoketest.sms + +all: $(BINS) + +ASRC = $(wildcard *.s) +CSRC = $(wildcard *.c) + +OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link single file in one pass + +%.o: %.c + $(CC) -c -o $@ $< + +%.o: %.s + $(CC) -c -o $@ $< + +$(BINS): $(OBJS) + $(CC) -Wm-yS -o $@ $^ + rm -f *.map *.noi *.ihx *.lst + +clean: + rm -f *.o *.lst *.map *.sms *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/sms/smoke/assets.c b/gbdk-lib/examples/sms/smoke/assets.c @@ -0,0 +1,46 @@ +#pragma bank 2 + +#include <sms/sms.h> + +BANKREF(earth_data) +const unsigned char earth_data[] = { + + /* Tile 0x00 */ + 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87, + 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2, + 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0, + 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A, + 0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x08 */ + 0x07,0x07,0x1E,0x19,0x20,0x3F,0x40,0x7F,0x42,0x7D,0x81,0xFE,0x81,0xFE,0x83,0xFC, + 0xD7,0xA8,0xBB,0xC4,0x6E,0x51,0x7C,0x43,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0xE8,0x18,0xF4,0x0C,0xF4,0x0C,0xFE,0x02,0xFE,0x02,0xFE,0x02, + 0xFE,0x02,0x7E,0x82,0x3C,0xC4,0x3C,0xC4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1B,0x1C,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xE0,0x9F,0x90,0xEF,0x89,0xF6, + 0x8D,0xF2,0x9F,0xE0,0x5E,0x61,0x6F,0x50,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xB0,0x70,0x28,0xD8,0x04,0xFC,0x2C,0xD4,0x1E,0xE2,0x1E,0xE2,0x3E,0xC2, + 0x7E,0x82,0xB6,0x4A,0xE4,0x1C,0xC4,0x3C,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x10 */ + 0x07,0x07,0x18,0x1F,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xEE,0x91,0xF1,0x8E,0xE0,0x9F, + 0xE0,0x9F,0xF1,0x8E,0x71,0x4E,0x72,0x4D,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0xF0,0x30,0x08,0xF8,0x04,0xFC,0x04,0xFC,0x02,0xFE,0x02,0xFE,0x92,0x6E, + 0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + 0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1, + 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2, + 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00, + + /* Tile 0x18 */ + 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE, + 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00, + 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E, + 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00 +}; + +BANKREF(earth_data_size) +const unsigned int earth_data_size = sizeof(earth_data); diff --git a/gbdk-lib/examples/sms/smoke/banked.c b/gbdk-lib/examples/sms/smoke/banked.c @@ -0,0 +1,7 @@ +#pragma bank 3 + +#include <stdint.h> + +uint16_t banked_func(uint8_t be, uint8_t ef) __banked { + return ((be << 8) | ef); +} + diff --git a/gbdk-lib/examples/sms/smoke/ram_bank0.s b/gbdk-lib/examples/sms/smoke/ram_bank0.s @@ -0,0 +1,6 @@ + .area _DATA_0 + +_array0:: + .ds 0x10 +_array1:: + .ds 0x10 + diff --git a/gbdk-lib/examples/sms/smoke/ram_bank1.s b/gbdk-lib/examples/sms/smoke/ram_bank1.s @@ -0,0 +1,6 @@ + .area _DATA_1 + +_array2:: + .ds 0x04 +_array3:: + .ds 0x06 + diff --git a/gbdk-lib/examples/sms/smoke/smoketest.c b/gbdk-lib/examples/sms/smoke/smoketest.c @@ -0,0 +1,87 @@ +#include <sms/sms.h> + +BANKREF_EXTERN(earth_data) +extern const unsigned char earth_data[]; + +BANKREF_EXTERN(earth_data_size) +extern const unsigned int earth_data_size; + +const uint8_t tilemap[] = {2, 4, 6, 8, 3, 5, 7, 9}; + +uint16_t banked_func(uint8_t be, uint8_t ef) __banked; + +int16_t x = 8 << 4, y = 0; +int8_t xspd = 0, yspd = 0; + +uint8_t anim = 0, tick = 0; + +joypads_t joy; +void main() { + HIDE_LEFT_COLUMN; + SPRITES_8x16; + DISPLAY_ON; + +// vmemcpy(0x4000, earth_data, sizeof(earth_data)); + + SWITCH_ROM(BANK(earth_data)); + if (banked_func(0xBE, 0xEF) == 0xBEEF) { + set_bkg_2bpp_data(2, earth_data_size >> 4, earth_data); + set_sprite_2bpp_data(0, earth_data_size >> 4, earth_data); + set_sprite_tile(0, 0); + set_sprite_tile(1, 2); + } + + set_bkg_tiles(4, 10, 4, 2, tilemap); + + joypad_init(2, &joy); + + while(TRUE) { + joypad_ex(&joy); + + if (joy.joy0 & J_LEFT) { + if (xspd > -32) xspd -= 2; + } else if (joy.joy0 & J_RIGHT) { + if (xspd < 32) xspd += 2; + } else { + if (xspd < 0) xspd++; else if (xspd > 0) xspd--; + } + + if (joy.joy0 & J_UP) { + if (yspd > -32) yspd -= 2; + } else if (joy.joy0 & J_DOWN) { + if (yspd < 32) yspd += 2; + } else { + if (yspd < 0) yspd++; else if (yspd > 0) yspd--; + } + + x += xspd; + if (x < (8 << 4)) x = 8 << 4; else if (x > (30 * 8) << 4) x = (30 * 8) << 4; + + + y += yspd; + if (y < 0) y = 0; else if (y > (22 * 8) << 4) y = (22 * 8) << 4; + + tick++; tick &= 7; + if (!tick) { + anim++; if (anim == 7) anim = 0; + set_sprite_tile(0, anim << 2); + set_sprite_tile(1, (anim << 2) + 2); + } + + move_sprite(0, x >> 4, y >> 4); + move_sprite(1, (x >> 4) + 8, y >> 4); + + if (joy.joy1 & J_LEFT) { + scroll_bkg(-1, 0); + } else if (joy.joy1 & J_RIGHT) { + scroll_bkg(1, 0); + } + if (joy.joy1 & J_UP) { + scroll_bkg(0, -1); + } else if (joy.joy1 & J_DOWN) { + scroll_bkg(0, 1); + } + + wait_vbl_done(); + } +} diff --git a/gbdk-lib/include/asm/types.h b/gbdk-lib/include/asm/types.h @@ -57,11 +57,20 @@ typedef INT32 DWORD; /** Unsigned 32 bit */ typedef UINT32 UDWORD; -/** Useful definition for fixed point values */ +/** Useful definition for working with 8 bit + 8 bit fixed point values + + Use `.w` to access the variable as unsigned 16 bit type. + + Use `.b.h` and `.b.l` (or just `.h` and `.l`) to directly access it's high and low unsigned 8 bit values. + */ typedef union _fixed { struct { UBYTE l; UBYTE h; + }; + struct { + UBYTE l; + UBYTE h; } b; UWORD w; } fixed; diff --git a/gbdk-lib/include/asm/z80/provides.h b/gbdk-lib/include/asm/z80/provides.h @@ -0,0 +1,4 @@ +#define USE_C_MEMCPY 0 +#define USE_C_STRCPY 0 +#define USE_C_STRCMP 0 + diff --git a/gbdk-lib/include/asm/z80/stdarg.h b/gbdk-lib/include/asm/z80/stdarg.h @@ -0,0 +1,18 @@ +#ifndef ASM_Z80_STDARG_INCLUDE +#define ASM_Z80_STDARG_INCLUDE + +/* sdcc pushes right to left with the real sizes, not cast up + to an int. + so printf(int, char, long) + results in push long, push char, push int + On the z80 the stack grows down, so the things seem to be in + the correct order. + */ + +typedef unsigned char * va_list; +#define va_start(list, last) list = (unsigned char *)&last + sizeof(last) +#define va_arg(list, type) *((type *)((list += sizeof(type)) - sizeof(type))) + +#define va_end(list) + +#endif diff --git a/gbdk-lib/include/asm/z80/types.h b/gbdk-lib/include/asm/z80/types.h @@ -0,0 +1,46 @@ +/** @file asm/gbz80/types.h + @anchor file_asm_gbz80_types_h + Types definitions for the gb. +*/ +#ifndef ASM_Z80_TYPES_INCLUDE +#define ASM_Z80_TYPES_INCLUDE + +#if SDCC_PORT!=z80 +#error gbz80 only. +#endif + +#define NONBANKED __nonbanked +#define BANKED __banked +#define CRITICAL __critical +#define INTERRUPT __interrupt + +/** Signed eight bit. + */ +typedef signed char INT8; +/** Unsigned eight bit. + */ +typedef unsigned char UINT8; +/** Signed sixteen bit. + */ +typedef signed int INT16; +/** Unsigned sixteen bit. + */ +typedef unsigned int UINT16; +/** Signed 32 bit. + */ +typedef signed long INT32; +/** Unsigned 32 bit. + */ +typedef unsigned long UINT32; + +#ifndef __SIZE_T_DEFINED +#define __SIZE_T_DEFINED +typedef int size_t; +#endif + +/** Returned from clock + @see clock +*/ +typedef UINT16 clock_t; + +#endif diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -4,7 +4,7 @@ #ifndef _GB_H #define _GB_H -#define __GBDK_VERSION 404 +#define __GBDK_VERSION 405 #include <types.h> #include <stdint.h> @@ -308,6 +308,19 @@ extern uint8_t _cpu; */ #define CGB_TYPE 0x11 +/** GBA detection + + @see GBA_DETECTED, GBA_NOT_DETECTED, _cpu +*/ +extern uint8_t _is_GBA; + +/** Hardware Model: DMG, CGB or MGB. @see _cpu +*/ +#define GBA_NOT_DETECTED 0x00 +/** Hardware Model: GBA. @see _cpu +*/ +#define GBA_DETECTED 0x01 + /** Global Time Counter in VBL periods (60Hz) Increments once per Frame diff --git a/gbdk-lib/include/gb/hardware.h b/gbdk-lib/include/gb/hardware.h @@ -1,6 +1,6 @@ /** @file gb/hardware.h Defines that let the GB's hardware registers be accessed - from C. + from C. See the @ref Pandocs for more details on each register. */ @@ -152,6 +152,32 @@ __BYTE_REG AUD3WAVE[16]; __REG LCDC_REG; /** LCD control */ #define rLCDC LCDC_REG +#ifdef __TARGET_ap +#define LCDCF_OFF 0b00000000 +#define LCDCF_ON 0b00000001 +#define LCDCF_WIN9800 0b00000000 +#define LCDCF_WIN9C00 0b00000010 +#define LCDCF_WINOFF 0b00000000 +#define LCDCF_WINON 0b00000100 +#define LCDCF_BG8800 0b00000000 +#define LCDCF_BG8000 0b00001000 +#define LCDCF_BG9800 0b00000000 +#define LCDCF_BG9C00 0b00010000 +#define LCDCF_OBJ8 0b00000000 +#define LCDCF_OBJ16 0b00100000 +#define LCDCF_OBJOFF 0b00000000 +#define LCDCF_OBJON 0b01000000 +#define LCDCF_BGOFF 0b00000000 +#define LCDCF_BGON 0b10000000 +#define LCDCF_B_ON 0 +#define LCDCF_B_WIN9C00 1 +#define LCDCF_B_WINON 2 +#define LCDCF_B_BG8000 3 +#define LCDCF_B_BG9C00 4 +#define LCDCF_B_OBJ16 5 +#define LCDCF_B_OBJON 6 +#define LCDCF_B_BGON 7 +#else #define LCDCF_OFF 0b00000000 #define LCDCF_ON 0b10000000 #define LCDCF_WIN9800 0b00000000 @@ -176,10 +202,31 @@ __REG LCDC_REG; /** LCD control */ #define LCDCF_B_OBJ16 2 #define LCDCF_B_OBJON 1 #define LCDCF_B_BGON 0 +#endif __REG STAT_REG; /** LCD status */ #define rSTAT STAT_REG +#ifdef __TARGET_ap +#define STATF_LYC 0b00000010 +#define STATF_MODE10 0b00000100 +#define STATF_MODE01 0b00001000 +#define STATF_MODE00 0b00010000 +#define STATF_LYCF 0b00100000 +#define STATF_HBL 0b00000000 +#define STATF_VBL 0b10000000 +#define STATF_OAM 0b01000000 +#define STATF_LCD 0b11000000 +#define STATF_BUSY 0b01000000 +#define STATF_B_LYC 1 +#define STATF_B_MODE10 2 +#define STATF_B_MODE01 3 +#define STATF_B_MODE00 4 +#define STATF_B_LYCF 5 +#define STATF_B_VBL 7 +#define STATF_B_OAM 6 +#define STATF_B_BUSY 6 +#else #define STATF_LYC 0b01000000 #define STATF_MODE10 0b00100000 #define STATF_MODE01 0b00010000 @@ -198,6 +245,7 @@ __REG STAT_REG; /** LCD status */ #define STATF_B_VBL 0 #define STATF_B_OAM 1 #define STATF_B_BUSY 1 +#endif __REG SCY_REG; /** Scroll Y */ #define rSCY diff --git a/gbdk-lib/include/sms/hardware.h b/gbdk-lib/include/sms/hardware.h @@ -0,0 +1,175 @@ +/** @file sms/hardware.h + Defines that let the SMS/GG hardware registers be accessed + from C. +*/ +#ifndef _HARDWARE_H +#define _HARDWARE_H + +#include <types.h> + +#define __BYTES extern UBYTE +#define __BYTE_REG extern volatile UBYTE + +static volatile __sfr __at(0x3E) MEMORY_CTL; + +#define MEMCTL_JOYON 0b00000000 +#define MEMCTL_JOYOFF 0b00000100 +#define MEMCTL_BASEON 0b00000000 +#define MEMCTL_BASEOFF 0b00001000 +#define MEMCTL_RAMON 0b00000000 +#define MEMCTL_RAMOFF 0b00010000 +#define MEMCTL_CROMON 0b00000000 +#define MEMCTL_CROMOFF 0b00100000 +#define MEMCTL_ROMON 0b00000000 +#define MEMCTL_ROMOFF 0b01000000 +#define MEMCTL_EXTON 0b00000000 +#define MEMCTL_EXTOFF 0b10000000 + +static volatile __sfr __at(0x3F) JOY_CTL; + +#define JOY_P1_LATCH 0b00000010 +#define JOY_P2_LATCH 0b00001000 + +static volatile __sfr __at(0x7E) VCOUNTER; +static volatile __sfr __at(0x7F) PSG; +static volatile __sfr __at(0x7F) HCOUNTER; + +static volatile __sfr __at(0xBE) VDP_DATA; +static volatile __sfr __at(0xBF) VDP_CMD; +static volatile __sfr __at(0xBF) VDP_STATUS; + +#define STATF_INT_VBL 0b10000000 +#define STATF_9_SPR 0b01000000 +#define STATF_SPR_COLL 0b00100000 + +#define VDP_REG_MASK 0b10000000 +#define VDP_R0 0b10000000 +extern UBYTE shadow_VDP_R0; + +#define R0_VSCRL 0b00000000 +#define R0_VSCRL_INH 0b10000000 +#define R0_HSCRL 0b00000000 +#define R0_HSCRL_INH 0b01000000 +#define R0_NO_LCB 0b00000000 +#define R0_LCB 0b00100000 +#define R0_IE1_OFF 0b00000000 +#define R0_IE1 0b00010000 +#define R0_SS_OFF 0b00000000 +#define R0_SS 0b00001000 +#define R0_DEFAULT 0b00000110 +#define R0_ES_OFF 0b00000000 +#define R0_ES 0b00000001 + +#define VDP_R1 0b10000001 +extern UBYTE shadow_VDP_R1; + +#define R1_DEFAULT 0b10000000 +#define R1_DISP_OFF 0b00000000 +#define R1_DISP_ON 0b01000000 +#define R1_IE_OFF 0b00000000 +#define R1_IE 0b00100000 +#define R1_SPR_8X8 0b00000000 +#define R1_SPR_8X16 0b00000010 + +#define VDP_R2 0b10000010 +extern UBYTE shadow_VDP_R2; + +#define R2_MAP_0x3800 0xFF +#define R2_MAP_0x3000 0xFD +#define R2_MAP_0x2800 0xFB +#define R2_MAP_0x2000 0xF9 +#define R2_MAP_0x1800 0xF7 +#define R2_MAP_0x1000 0xF5 +#define R2_MAP_0x0800 0xF3 +#define R2_MAP_0x0000 0xF1 + +#define VDP_R3 0b10000011 +extern UBYTE shadow_VDP_R3; +#define VDP_R4 0b10000100 +extern UBYTE shadow_VDP_R4; +#define VDP_R5 0b10000101 +extern UBYTE shadow_VDP_R5; + +#define R5_SAT_0x3F00 0xFF +#define R5_SAT_MASK 0b10000001 + +#define VDP_R6 0b10000110 +extern UBYTE shadow_VDP_R6; + +#define R6_BANK0 0xFB +#define R6_DATA_0x0000 0xFB +#define R6_BANK1 0xFF +#define R6_DATA_0x2000 0xFF + +#define VDP_R7 0b10000111 +extern UBYTE shadow_VDP_R7; +#define VDP_RBORDER 0b10000111 +extern UBYTE shadow_VDP_RBORDER; + +#define R7_COLOR_MASK 0b11110000 + +#define VDP_R8 0b10001000 +extern UBYTE shadow_VDP_R8; +#define VDP_RSCX 0b10001000 +extern UBYTE shadow_VDP_RSCX; + +#define VDP_R9 0b10001001 +extern UBYTE shadow_VDP_R9; +#define VDP_RSCY 0b10001001 +extern UBYTE shadow_VDP_RSCY; + +#define VDP_R10 0b10001010 +extern UBYTE shadow_VDP_R10; + +#define R10_INT_OFF 0xFF +#define R10_INT_EVERY 0x00 + +static volatile __sfr __at(0xDC) JOY_PORT1; + +#define JOY_P1_UP 0b00000001 +#define JOY_P1_DOWN 0b00000010 +#define JOY_P1_LEFT 0b00000100 +#define JOY_P1_RIGHT 0b00001000 +#define JOY_P1_SW1 0b00010000 +#define JOY_P1_TRIGGER 0b00010000 +#define JOY_P1_SW2 0b00100000 +#define JOY_P2_UP 0b01000000 +#define JOY_P2_DOWN 0b10000000 + +static volatile __sfr __at(0xDD) JOY_PORT2; + +#define JOY_P2_LEFT 0b00000001 +#define JOY_P2_RIGHT 0b00000010 +#define JOY_P2_SW1 0b00000100 +#define JOY_P2_TRIGGER 0b00000100 +#define JOY_P2_SW2 0b00001000 +#define JOY_RESET 0b00010000 +#define JOY_P1_LIGHT 0b01000000 +#define JOY_P2_LIGHT 0b10000000 + +static volatile __sfr __at(0xF0) FMADDRESS; +static volatile __sfr __at(0xF1) FMDATA; +static volatile __sfr __at(0xF2) AUDIOCTRL; + +static volatile UBYTE __at(0xfffc) RAM_CONTROL; + +#define RAMCTL_BANK 0b00000100 +#define RAMCTL_ROM 0b00000000 +#define RAMCTL_RAM 0b00001000 +#define RAMCTL_RO 0b00010000 +#define RAMCTL_PROT 0b10000000 + +static volatile UBYTE __at(0xfff8) GLASSES_3D; + +static volatile UBYTE __at(0xfffd) MAP_FRAME0; +static volatile UBYTE __at(0xfffe) MAP_FRAME1; +static volatile UBYTE __at(0xffff) MAP_FRAME2; + +#define SYSTEM_PAL 0x00 +#define SYSTEM_NTSC 0x01 + +static volatile UBYTE VDP_ATTR_SHIFT; + +#define VDP_SAT_TERM 0xD0 + +#endif diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -0,0 +1,412 @@ +/** @file sms/sms.h + SMS/GG specific functions. +*/ +#ifndef _SMS_H +#define _SMS_H + +#define __GBDK_VERSION 405 + +#include <types.h> +#include <stdint.h> +#include <sms/hardware.h> + +#define VBK_REG VDP_ATTR_SHIFT + +/** Joypad bits. + A logical OR of these is used in the wait_pad and joypad + functions. For example, to see if the B button is pressed + try + + uint8_t keys; + keys = joypad(); + if (keys & J_B) { + ... + } + + @see joypad + */ +#define J_START 0b01000000 +#define J_SELECT 0b01000000 +#define J_B 0b00100000 +#define J_A 0b00010000 +#define J_DOWN 0b00000010 +#define J_UP 0b00000001 +#define J_LEFT 0b00000100 +#define J_RIGHT 0b00001000 + +#define __WRITE_VDP_REG(REG, v) shadow_##REG=(v);__critical{VDP_CMD=(shadow_##REG),VDP_CMD=REG;} +#define __READ_VDP_REG(REG) shadow_##REG + +void WRITE_VDP_CMD(uint16_t cmd) __z88dk_fastcall __preserves_regs(b, c, d, e, iyh, iyl); +void WRITE_VDP_DATA(uint16_t data) __z88dk_fastcall __preserves_regs(b, c, d, e, iyh, iyl); + +/** Interrupt handlers + */ +typedef void (*int_handler)(void) NONBANKED; + +/** Removes the VBL interrupt handler. + @see add_VBL() +*/ +void remove_VBL(int_handler h) __z88dk_fastcall __preserves_regs(iyh, iyl); + +/** Removes the LCD interrupt handler. + @see add_LCD(), remove_VBL() +*/ +void remove_LCD(int_handler h) __z88dk_fastcall __preserves_regs(b, c, iyh, iyl); + +void remove_TIM(int_handler h); +void remove_SIO(int_handler h); +void remove_JOY(int_handler h); + +/** Adds a V-blank interrupt handler. +*/ +void add_VBL(int_handler h) __z88dk_fastcall __preserves_regs(d, e, iyh, iyl); + +/** Adds a LCD interrupt handler. +*/ +void add_LCD(int_handler h) __z88dk_fastcall __preserves_regs(b, c, iyh, iyl); + +void add_TIM(int_handler h); +void add_SIO(int_handler h); +void add_JOY(int_handler h); + +inline void move_bkg(uint8_t x, uint8_t y) { + __WRITE_VDP_REG(VDP_RSCX, x); + __WRITE_VDP_REG(VDP_RSCY, y); +} + +inline void scroll_bkg(int8_t x, int8_t y) { + __WRITE_VDP_REG(VDP_RSCX, __READ_VDP_REG(VDP_RSCX) + x); + __WRITE_VDP_REG(VDP_RSCY, __READ_VDP_REG(VDP_RSCY) + y); +} + +/** HALTs the CPU and waits for the vertical blank interrupt (VBL) to finish. + + This is often used in main loops to idle the CPU at low power + until it's time to start the next frame. It's also useful for + syncing animation with the screen re-draw. + + Warning: If the VBL interrupt is disabled, this function will + never return. If the screen is off this function returns + immediately. +*/ +void wait_vbl_done(void) __preserves_regs(b, c, d, e, h, l, iyh, iyl); + +/** Turns the display off. + + @see DISPLAY_ON +*/ +inline void display_off(void) { + __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) &= (~R1_DISP_ON)); +} + +/** Turns the display back on. + @see display_off, DISPLAY_OFF +*/ +#define DISPLAY_ON \ + __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) |= R1_DISP_ON) + +/** Turns the display off immediately. + @see display_off, DISPLAY_ON +*/ +#define DISPLAY_OFF \ + display_off(); + +/** Blanks leftmost column, so it is not garbaged when you use horizontal scroll + @see SHOW_LEFT_COLUMN +*/ +#define HIDE_LEFT_COLUMN \ + __WRITE_VDP_REG(VDP_R0, __READ_VDP_REG(VDP_R0) |= R0_LCB) + +/** Shows leftmost column + @see HIDE_LEFT_COLUMN +*/ +#define SHOW_LEFT_COLUMN \ + __WRITE_VDP_REG(VDP_R0, __READ_VDP_REG(VDP_R0) &= (~R0_LCB)) + +/** Turns on the sprites layer. + Not yet implemented +*/ +#define SHOW_SPRITES + +/** Turns off the sprites layer. + Not yet implemented +*/ +#define HIDE_SPRITES + +/** Sets sprite size to 8x16 pixels, two tiles one above the other. +*/ +#define SPRITES_8x16 \ + __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) |= R1_SPR_8X16) + +/** Sets sprite size to 8x8 pixels, one tile. +*/ +#define SPRITES_8x8 \ + __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) &= (~R1_SPR_8X16)) + +/** Tracks current active ROM bank in frame 1 +*/ +#define _current_bank MAP_FRAME1 +#define CURRENT_BANK MAP_FRAME1 + +/** Obtains the __bank number__ of VARNAME + + @param VARNAME Name of the variable which has a __bank_VARNAME companion symbol which is adjusted by bankpack + + Use this to obtain the bank number from a bank reference + created with @ref BANKREF(). + + @see BANKREF_EXTERN(), BANKREF() +*/ +#ifndef BANK +#define BANK(VARNAME) ( (uint8_t) & __bank_ ## VARNAME ) +#endif + +/** Creates a reference for retrieving the bank number of a variable or function + + @param VARNAME Variable name to use, which may be an existing identifier + + @see BANK() for obtaining the bank number of the included data. + + More than one `BANKREF()` may be created per file, but each call should + always use a unique VARNAME. + + Use @ref BANKREF_EXTERN() within another source file + to make the variable and it's data accesible there. +*/ +#define BANKREF(VARNAME) void __func_ ## VARNAME() __banked __naked { \ +__asm \ + .local b___func_ ## VARNAME \ + ___bank_ ## VARNAME = b___func_ ## VARNAME \ + .globl ___bank_ ## VARNAME \ +__endasm; \ +} + +/** Creates extern references for accessing a BANKREF() generated variable. + + @param VARNAME Name of the variable used with @ref BANKREF() + + This makes a @ref BANKREF() reference in another source + file accessible in the current file for use with @ref BANK(). + + @see BANKREF(), BANK() +*/ +#define BANKREF_EXTERN(VARNAME) extern const void __bank_ ## VARNAME; + + +/** Makes switch the active ROM bank in frame 1 + @param b ROM bank to switch to +*/ + +#define SWITCH_ROM(b) MAP_FRAME1=(b) +#define SWITCH_ROM1 SWITCH_ROM + +/** Makes switch the active ROM bank in frame 2 + @param b ROM bank to switch to +*/ + +#define SWITCH_ROM2(b) MAP_FRAME2=(b) + +/** Switches RAM bank + @param b SRAM bank to switch to +*/ + +#define SWITCH_RAM (((b)&1)?RAM_CONTROL|=RAMCTL_BANK:RAM_CONTROL&=(~RAMCTL_BANK)) + +/** Enables RAM +*/ + +#define ENABLE_RAM RAM_CONTROL|=RAMCTL_RAM + +/** Disables RAM +*/ + +#define DISABLE_RAM RAM_CONTROL&=(~RAMCTL_RAM) + + +/** Reads and returns the current state of the joypad. +*/ +uint8_t joypad(void) __preserves_regs(b, c, d, e, h, iyh, iyl); + +/** Waits until at least one of the buttons given in mask are pressed. +*/ +uint8_t waitpad(uint8_t mask) __z88dk_fastcall __preserves_regs(b, c, d, e, iyh, iyl); + +/** Waits for the directional pad and all buttons to be released. + + Note: Checks in a loop that doesn't HALT at all, so the CPU + will be maxed out until this call returns. +*/ +void waitpadup(void) __preserves_regs(b, c, d, e, iyh, iyl); + +/** Multiplayer joypad structure. + + Must be initialized with @ref joypad_init() first then it + may be used to poll all avaliable joypads with @ref joypad_ex() +*/ +typedef struct { + uint8_t npads; + union { + struct { + uint8_t joy0, joy1, joy2, joy3; + }; + uint8_t joypads[4]; + }; +} joypads_t; + +/** Initializes joypads_t structure for polling multiple joypads + @param npads number of joypads requested (1, 2 or 4) + @param joypads pointer to joypads_t structure to be initialized + + Only required for @ref joypad_ex, not required for calls to regular @ref joypad() + @returns number of joypads avaliable + @see joypad_ex(), joypads_t +*/ +uint8_t joypad_init(uint8_t npads, joypads_t * joypads) __z88dk_callee; + +/** Polls all avaliable joypads + @param joypads pointer to joypads_t structure to be filled with joypad statuses, + must be previously initialized with joypad_init() + + @see joypad_init(), joypads_t +*/ +void joypad_ex(joypads_t * joypads) __z88dk_fastcall __preserves_regs(iyh, iyl); + + +#ifdef __TARGET_sms +#define RGB(r,g,b) ((r)|((g)<<2)|((b)<<4)) +#define RGB8(r,g,b) (((r)>>6)|(((g)>>6)<<2)|(((b)>>6)<<4)) +#define RGBHTML(RGB24bit) (((RGB24bit)>>22)|((((RGB24bit)&0xFFFF)>>14)<<2)|((((RGB24bit)&0xFF)>>6)<<4)) +#else +#ifdef __TARGET_gg +#define RGB(r,g,b) ((r)|((g)<<4)|((b)<<8)) +#define RGB8(r,g,b) (((r)>>4)|(((g)>>4)<<4)|(((b)>>4)<<8)) +#define RGBHTML(RGB24bit) (((RGB24bit)>>20)|((((RGB24bit)&0xFFFF)>>12)<<4)|((((RGB24bit)&0xFF)>>4)<<8)) +#endif +#endif + +#define set_bkg_palette_entry set_palette_entry +#define set_sprite_palette_entry(palette,entry,rgb_data) set_palette_entry(1,entry,rgb_data) +void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) __z88dk_callee __preserves_regs(iyh, iyl); +#define set_bkg_palette set_palette +#define set_sprite_palette(first_palette,nb_palettes,rgb_data) set_palette(1,1,rgb_data) +void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee; + +#define set_bkg_data set_tile_data +#define set_sprite_data(start,ntiles,src) set_tile_data((uint8_t)(start)+0x100,(uint8_t)(ntiles),src) +void set_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); +#define set_bkg_2bpp_data set_tile_2bpp_data +#define set_sprite_2bpp_data(start,ntiles,src) set_tile_2bpp_data((uint8_t)(start)+0x100,(uint8_t)(ntiles),src) +void set_tile_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); + +void vmemcpy(uint16_t dst, const void *src, uint16_t size) __z88dk_callee __preserves_regs(iyh, iyl); + +void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) __z88dk_callee __preserves_regs(iyh, iyl); +#define set_bkg_tiles set_tile_map_compat +#define set_win_tiles set_tile_map_compat +void set_tile_map_compat(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) __z88dk_callee __preserves_regs(iyh, iyl); + +/** Shadow OAM array in WRAM, that is transferred into the real OAM each VBlank +*/ +extern volatile uint8_t shadow_OAM[]; + +/** MSB of shadow_OAM address is used by OAM copying routine +*/ +extern volatile uint8_t _shadow_OAM_base; + +/** Flag for disabling of OAM copying routine +*/ +extern volatile uint8_t _shadow_OAM_OFF; + +/** Disable OAM copy each VBlank (note: there is no real DMA, this name is for compatibility with GB library) +*/ +#define DISABLE_OAM_DMA \ + _shadow_OAM_OFF = 1 + +/** Enable OAM DMA copy each VBlank and set it to transfer default shadow_OAM array +*/ +#define ENABLE_OAM_DMA \ + _shadow_OAM_OFF = 0 + +/** Enable OAM DMA copy each VBlank and set it to transfer any 256-byte aligned array +*/ +inline void SET_SHADOW_OAM_ADDRESS(void * address) { + _shadow_OAM_base = (uint8_t)((uint16_t)address >> 8); +} + +/** Sets sprite number __nb__in the OAM to display tile number __tile__. + + @param nb Sprite number, range 0 - 39 + @param tile Selects a tile (0 - 255) from memory at 8000h - 8FFFh + \n In CGB Mode this could be either in VRAM Bank + \n 0 or 1, depending on Bit 3 of the OAM Attribute Flag + \n (see @ref set_sprite_prop) + + In 8x16 mode: + \li The sprite will also display the next tile (__tile__ + 1) + directly below (y + 8) the first tile. + \li The lower bit of the tile number is ignored: + the upper 8x8 tile is (__tile__ & 0xFE), and + the lower 8x8 tile is (__tile__ | 0x01). + \li See: @ref SPRITES_8x16 +*/ +inline void set_sprite_tile(uint8_t nb, uint8_t tile) { + shadow_OAM[0x41+(nb << 1)] = tile; +} + + +/** Returns the tile number of sprite number __nb__ in the OAM. + +@param nb Sprite number, range 0 - 39 + +@see set_sprite_tile for more details +*/ +inline uint8_t get_sprite_tile(uint8_t nb) { + return shadow_OAM[0x41+(nb << 1)]; +} + +/** Moves sprite number __nb__ to the __x__, __y__ position on the screen. + + @param nb Sprite number, range 0 - 39 + @param x X Position. Specifies the sprites horizontal position on the screen (minus 8). + \n An offscreen value (X=0 or X>=168) hides the sprite, but the sprite + still affects the priority ordering - a better way to hide a sprite is to set + its Y-coordinate offscreen. + @param y Y Position. Specifies the sprites vertical position on the screen (minus 16). + \n An offscreen value (for example, Y=0 or Y>=160) hides the sprite. + + Moving the sprite to 0,0 (or similar off-screen location) will hide it. +*/ +inline void move_sprite(uint8_t nb, uint8_t x, uint8_t y) { + shadow_OAM[nb] = (y < VDP_SAT_TERM) ? y : 0xC0; + shadow_OAM[0x40+(nb << 1)] = x; +} + + +/** Moves sprite number __nb__ relative to its current position. + + @param nb Sprite number, range 0 - 39 + @param x Number of pixels to move the sprite on the __X axis__ + \n Range: -128 - 127 + @param y Number of pixels to move the sprite on the __Y axis__ + \n Range: -128 - 127 + + @see move_sprite for more details about the X and Y position + */ +inline void scroll_sprite(uint8_t nb, int8_t x, int8_t y) { + uint8_t new_y = shadow_OAM[nb] + y; + shadow_OAM[nb] = (new_y < VDP_SAT_TERM) ? new_y : 0xC0; + shadow_OAM[0x40+(nb << 1)] = x; +} + + +/** Hides sprite number __nb__ by moving it to zero position by Y. + + @param nb Sprite number, range 0 - 39 + */ +inline void hide_sprite(uint8_t nb) { + shadow_OAM[nb] = 0xC0; +} + + +#endif /* _SMS_H */ diff --git a/gbdk-lib/libc/Makefile b/gbdk-lib/libc/Makefile @@ -3,11 +3,11 @@ .EXPORT_ALL_VARIABLES: ifeq ($(PORTS),) - PORTS = gbz80 + PORTS = gbz80 z80 endif ifeq ($(PLATFORMS),) - PLATFORMS = gb + PLATFORMS = gb ap gg sms endif TOPDIR = .. @@ -20,7 +20,6 @@ CSRC = atoi.c atol.c isalpha.c isdigit.c \ __assert.c \ _modulong.c _modslong.c _divulong.c _divslong.c _mullong.c \ bsearch.c qsort.c atomic_flag_clear.c \ - bcd.c \ _memmove.c free.c malloc.c realloc.c calloc.c include $(TOPDIR)/Makefile.common @@ -33,7 +32,7 @@ ports: for i in $(PORTS); do make port THIS=$$i PORT=$$i; done platforms: - for i in $(PLATFORMS); do make -C $$i platform THIS=$$i; done + for j in $(PORTS); do for i in $(PLATFORMS); do if [ -d "targets/$$j/$$i" ]; then make -C targets/$$j/$$i platform THIS=$$i; fi done done # Make all the std libs # Make all the port specific libs @@ -49,6 +48,6 @@ ports-clean: for i in $(PORTS); do make -C asm/$$i clean THIS=$$i; done platform-clean: - for i in $(PLATFORMS); do make -C $$i clean PLAT=$$i; done + for j in $(PORTS); do for i in $(PLATFORMS); do if [ -d "targets/$$j/$$i" ]; then make -C $$i clean PLAT=$$i; fi done done include Makefile.rules diff --git a/gbdk-lib/libc/asm/gbz80/Makefile b/gbdk-lib/libc/asm/gbz80/Makefile @@ -7,7 +7,9 @@ THIS = gbz80 ASSRC = __sdcc_call_hl.s abs.s mul.s div.s shift.s crt0_rle.s \ itoa.s strlen.s reverse.s labs.s ltoa.s \ setjmp.s atomic_flag_test_and_set.s \ - _memcpy.s _memset.s _strcmp.s _strcpy.s + _memcpy.s _memset.s _strcmp.s _strcpy.s \ + rand.s arand.s \ + bcd.s include $(TOPDIR)/Makefile.common diff --git a/gbdk-lib/libc/asm/gbz80/arand.s b/gbdk-lib/libc/asm/gbz80/arand.s @@ -0,0 +1,126 @@ +;/*************************************************************************** +; * * +; * Module : arand.s * +; * * +; * Purpose : A random number generator using the lagged additive method * +; * * +; * Version : 1, January 11 1998 * +; * * +; * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) * +; * * +; **************************************************************************/ + + .globl .initrand + .globl _rand + + .area _BSS +.start_arand_vars: + +.randarr: + .ds 55 +.raxj: + .ds 0x01 +.raxk: + .ds 0x01 + +.end_arand_vars: + + .area _GSINIT + + XOR A + LD HL,#.start_arand_vars + LD C,#(.end_arand_vars - .start_arand_vars) + RST 0x28 + + .area _CODE + + ;; arand() operates on an array of 55 arbitrary values (here : bytes). + ;; It adds two values of the array together, replaces one of the values + ;; with the result, and returns the result. + ;; At start, the indices into the array refer to the 55th and 24th element. + ;; After each call, each index is decreased, and looped around if necessary. + ;; This kind of works, but the values produces are less good than those by + ;; rand(), mainly because it operates on bytes instead of words. + ;; Ref : D. E. Knuth, "The Art of Computer Programming" , Volume 2 + ;; + ;; Exit conditions + ;; DE = Random number (byte!) + ;; + ;; Registers used: + ;; all + ;; +_arand:: ; Banked + PUSH BC + LD D,#0 + LD HL,#.randarr-1 + LD A,(.raxj) + LD E,A + DEC A ; Decrease the pointer + JR NZ,1$ + LD A,#55 +1$: + LD (.raxj),A + ADD HL,DE + LD B,(HL) + + LD HL,#.randarr-1 ; Ooh... + LD A,(.raxk) + LD E,A + DEC A ; Decrease the pointer + JR NZ,2$ + LD A,#55 +2$: + LD (.raxk),A + ADD HL,DE + LD A,(HL) + + ADD B + LD (HL),A ; Store new value + + POP BC + + LD D,#0 + LD E,A + + RET + + ;; _initarand calls the _rand function to fill the array with random values + ;; Note that this also sets the seed value of the _rand function first, + ;; like _initrand + ;; + ;; Exit conditions + ;; None + ;; + ;; Registers used: + ;; all + ;; +_initarand:: ; Banked + LDA HL,2(SP) + CALL .initrand + + PUSH BC + LD A,#55 + LD HL,#.randarr +1$: + DEC A + LD (.raxj),A + LD B,H + LD C,L + CALL _rand + LD H,B + LD L,C + + LD A, E + LD (HL+),A + + LD A,(.raxj) + CP #0 + JR NZ,1$ + + LD A,#24 ; Now the array has been filled,set the pointers + LD (.raxj),A + LD A,#55 + LD (.raxk),A + + POP BC + RET diff --git a/gbdk-lib/libc/asm/gbz80/bcd.s b/gbdk-lib/libc/asm/gbz80/bcd.s @@ -0,0 +1,233 @@ +;-------------------------------------------------------------------------- +; bcd.s +; +; Copyright (C) 2020, Tony Pavlov +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .module bcd + + .area _BASE + +; void uint2bcd(uint16_t i, BCD * value) __naked +_uint2bcd:: + lda HL, 2(SP) + ld A, (HL+) ; DE: uint + ld E, A + ld A, (HL+) + ld D, A + ld A, (HL+) + ld H, (HL) + ld L, A ; HL: dest + + push BC + + ; clear value + xor A + ld BC, #-4 + + ld (HL+), A + ld (HL+), A + ld (HL+), A + ld (HL+), A + add HL, BC + + ld B, #16 +1$: + sla E + rl D + + ld A, (HL) + adc A + daa + ld (HL+), A + ld A, (HL) + adc A + daa + ld (HL+), A + ld A, (HL) + adc A + daa + ld (HL-), A + + dec HL + + dec B + jr NZ, 1$ + + pop BC + ret + +;void bcd_add(BCD * sour, BCD * value) __naked +_bcd_add:: + lda HL, 5(SP) + ld D, (HL) + dec HL + ld E, (HL) ; DE: value + dec HL + ld A, (HL-) + ld L, (HL) + ld H, A ; HL: sour + + or A ; clear C, HC + + ld A,(DE) + add (HL) + daa + ld (HL+), A + inc DE + + ld A,(DE) + adc (HL) + daa + ld (HL+), A + inc DE + + ld A,(DE) + adc (HL) + daa + ld (HL+), A + inc DE + + ld A,(DE) + adc (HL) + daa + ld (HL+), A + + ret + +; void bcd_sub(BCD * sour, BCD * value) __naked +_bcd_sub:: + lda HL, 2(SP) + ld E, (HL) + inc HL + ld D, (HL) ; DE: sour + inc HL + ld A, (HL+) + ld H, (HL) + ld L, A ; HL: value + + or A ; clear C, HC + + ld A,(DE) + sub (HL) + daa + ld (DE), A + inc DE + inc HL + + ld A,(DE) + sbc (HL) + daa + ld (DE), A + inc DE + inc HL + + ld A,(DE) + sbc (HL) + daa + ld (DE), A + inc DE + inc HL + + ld A,(DE) + sbc (HL) + daa + ld (DE), A + + ret + +;uint8_t bcd2text(BCD * bcd, uint8_t tile_offset, uint8_t * buffer) __naked +_bcd2text:: + push BC + + lda HL, 4(SP) + ld E, (HL) + inc HL + ld D, (HL) ; DE: bcd + inc HL + ld C, (HL) ; C: digit offset + inc HL + ld A, (HL+) + ld H, (HL) + ld L, A ; HL: buffer + + inc DE + inc DE + inc DE + + ld B, #0x0f + + ld A, (DE) + swap A + and B + add C + ld (HL+), A + ld A, (DE) + and B + add C + ld (HL+), A + dec DE + + ld A, (DE) + swap A + and B + add C + ld (HL+), A + ld A, (DE) + and B + add C + ld (HL+), A + dec DE + + ld A, (DE) + swap A + and B + add C + ld (HL+), A + ld A, (DE) + and B + add C + ld (HL+), A + dec DE + + ld A, (DE) + swap A + and B + add C + ld (HL+), A + ld A, (DE) + and B + add C + ld (HL+), A + dec DE + + xor A + ld (HL+), A + + ld D, A + ld E, #0x08 + + pop BC + ret diff --git a/gbdk-lib/libc/asm/gbz80/rand.s b/gbdk-lib/libc/asm/gbz80/rand.s @@ -0,0 +1,116 @@ +;/*************************************************************************** +; * * +; * Module : rand.s * +; * * +; * Purpose : A rand() generator using the linear congruential method * +; * * +; * Version : 1.01, January 7 1998 * +; * Added _initrand to set seed without recompiling * +; * 1, January 6 1998 * +; * * +; * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) * +; * * +; **************************************************************************/ + + ;; Why use an algorithm for generating random numbers? + ;; + ;; - Given a certain seed value, the same sequence of random numbers is generated + ;; every time. This is a good thing when debugging (reproducible). On the other + ;; hand, you've got 2^16 seed values, each of which will produce a sequence of + ;; numbers that stays different for any of the other sequences for 'an appreciable + ;; time.' (I can't say how long exactly.) + ;; + ;; - The linear congruential method is one of the 'best' random number generators + ;; around. However, this implementation uses a 16 bit accumulator, while at least + ;; 32 bits are needed for a generator that passes all the statistical tests. + ;; Still, I'm relatively confident that this is random enough for even the most + ;; demanding game. + ;; + ;; Compare this to getting random values from one of the hardware registers + ;; (not reproducible, might not have all values). An array might be the best bet + ;; if you don't need a lot of values (or have lots of memory spare), + ;; or if you want values to be within a certain range. + ;; And both would be faster than this. Also, this definitely isn't the fastest + ;; algorithm I know, and certainly for games less strict algorithms might be + ;; appropriate (shift and xor ?). + ;; It's your choice - but if you're doing Monte Carlo physics simulations on the + ;; GameBoy, this is a safe bet! + + .area _BSS +.randhi:: ; Storage for last random number (or seed) + .ds 0x01 +.randlo:: + .ds 0x01 + + .area _CODE + + ;; Random number generator using the linear congruential method + ;; X(n+1) = (a*X(n)+c) mod m + ;; with a = 17, m = 16 and c = $5c93 (arbitrarily) + ;; The seed value is also chosen arbitrarily as $a27e + ;; Ref : D. E. Knuth, "The Art of Computer Programming" , Volume 2 + ;; + ;; Exit conditions + ;; DE = Random number [0,2^16-1] + ;; + ;; Registers used: + ;; A, HL (need not be saved) and DE (return register) + ;; + +_rand:: ; Banked +_randw:: ; Banked + LD A,(.randlo) + LD L,A + LD E,A ; Save randlo + LD A,(.randhi) + LD D,A ; Save randhi + + SLA L ; * 16 + RLA + SLA L + RLA + SLA L + RLA + SLA L + RLA + LD H,A ; Save randhi*16 + + LD A,E ; Old randlo + ADD A,L ; Add randlo*16 + LD L,A ; Save randlo*17 + + LD A,H ; randhi*16 + ADC A,D ; Add old randhi + LD H,A ; Save randhi*17 + + LD A,L ; randlo*17 + ADD A,#0x93 + LD (.randlo),A + LD D,A ; Return register + LD A,H ; randhi*17 + ADC A,#0x5c + LD (.randhi),A + LD E,A ; Return register + + ;; Note D is the low byte,E the high byte. This is intentional because + ;; the high byte can be slightly 'more random' than the low byte, and I presume + ;; most will cast the return value to a uint8_t. As if someone will use this, tha! + RET + + ;; This sets the seed value. Call it whenever you like + ;; + ;; Exit conditions + ;; None + ;; + ;; Registers used: + ;; A, HL (need not be saved) and DE (return register) + ;; + .area _BASE +_initrand:: ; Non banked + LDA HL,2(SP) +.initrand:: + LD A,(HL+) + LD (.randlo),A + LD A,(HL) + LD (.randhi),A + RET diff --git a/gbdk-lib/libc/asm/z80/Makefile b/gbdk-lib/libc/asm/z80/Makefile @@ -0,0 +1,26 @@ +# z80 specific Makefile + +TOPDIR = ../../.. + +THIS = z80 + +ASSRC = __strreverse.s strcpy.s strlen.s \ + divmixed.s divsigned.s divunsigned.s \ + modsigned.s modunsigned.s modmixed.s \ + mul.s mulchar.s \ + __itoa.s __ltoa.s \ + __uitobcd.s __ultobcd.s \ + memcpy.s memmove.s \ + setjmp.s \ + abs.s \ + __sdcc_call_hl.s __sdcc_call_iy.s \ + atomic_flag_test_and_set.s __sdcc_critical.s \ + crtenter.s + +include $(TOPDIR)/Makefile.common + +AS = $(AS_Z80) + +include ../Makefile.port + + diff --git a/gbdk-lib/libc/asm/z80/__itoa.s b/gbdk-lib/libc/asm/z80/__itoa.s @@ -0,0 +1,231 @@ +;-------------------------------------------------------------------------- +; __itoa.s +; +; Copyright (C) 2020, Sergey Belyashov +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___itoa + .globl ___uitoa +; +;void __itoa(int value, char *string, unsigned char radix); +; +___itoa:: + push ix + ld ix, #0 + add ix, sp +; +; 4(ix) - value +; 6(ix) - string +; 8(ix) - radix +; + ld e, 4 (ix) + ld d, 5 (ix) + bit 7, d + jr Z, ___uitoa_de +;positive/negative numbers are supported only for radix=10 + ld a, 8 (ix) + cp a, #10 + jr NZ, ___uitoa_de +;add minus sign to result and inverse value + ld hl, #0 + or a, a + sbc hl, de + ex de, hl + ld l, 6 (ix) + ld h, 7 (ix) + ld (hl), #0x2D ;minus symbol + inc hl + ld 6 (ix), l + ld 7 (ix), h + jr ___uitoa_dehl +; +;void __uitoa(unsigned int value, char *string, unsigned char radix); +; +___uitoa:: + push ix + ld ix, #0 + add ix, sp +; +; 4(ix) - value +; 6(ix) - string +; 8(ix) - radix +; + ld e, 4 (ix) + ld d, 5 (ix) +; +___uitoa_de: + ld l, 6 (ix) + ld h, 7 (ix) +; +___uitoa_dehl: + ld a, e + or a, d + jr NZ, 100$ +; + ld (hl), #0x30 + inc hl + jp 190$ +100$: + ld a, 8 (ix) + cp a, #10 ;most popular radix + jr NZ, 110$ +; +;-------- decimal convertion +; this algorithm up to 2 times faster than generic +; + ld c, l + ld b, h + ld hl, #-4 + add hl, sp + ld sp, hl + push bc + push hl + push de + call ___uitobcd + ld hl, #4 + add hl, sp + ld sp, hl + pop de ;DE - pointer to string + inc hl + inc hl ;HL - pointer to BCD value + ld b, #3 ;number of bytes in BCD value + ld a, #0x30 ;ASCII code of '0' +103$: + rrd + ld (de), a + inc de + rrd + ld (de), a + inc de + inc hl + djnz 103$ +; +; pop af +; pop af +;skip trailing zeroes + ld b, #5 ;real BCD number is at most 5 digits + dec de ;so always skip last zero +105$: + dec de + ld a, (de) + cp a, #0x30 + jr NZ, 107$ ;break loop if non-zero found + djnz 105$ +107$: + inc de ;always point to symbol next to last significant + ex de, hl + jr 190$ +; +;--------------------------- +; +110$: + cp a, #2 + jr C, 190$ ;radix is less than 2 +; + ld c, a + dec c + and a, c + jr NZ, 150$ +; +;-------- radix is power of 2 +; +; DE - value, HL - pointer to string, C - mask +120$: + ld a, e + ld b, c +125$: + srl d + rr e + srl b + jr NZ, 125$ +; + and a, c + add a, #0x30 + cp a, #0x3A ;convert to 0...9A...Z + jr C, 130$ + add a, #7 +130$: + ld (hl), a + inc hl + ld a, e + or a, d + jr NZ, 120$ + jr 190$ +; +;--------------------------- +; +;-------- custom radix (generic algorithm) +; +150$: + ex de, hl +160$: + ld c, 8 (ix) + call ___divu16_8 + add a, #0x30 + cp a, #0x3A + jr C, 165$ + add a, #7 +165$: + ld (de), a + inc de + ld a, l + or h + jr NZ, 160$ + ex de, hl +; jr 190$ +; +;--------------------------- +; +;-------- finish string and reverse order +190$: + ld (hl), #0 + ld e, 6 (ix) + ld d, 7 (ix) + call ___strreverse_reg + ld sp, ix + pop ix + ret +; +; +;in: HL - divident, C - divisor +;out: HL - quotient, A - remainder +___divu16_8: + xor a, a + ld b, #16 +100$: + add hl, hl + rla + jr c, 110$ + cp a, c + jr c, 120$ +110$: + sub a, c + inc l +120$: + djnz 100$ + ret + diff --git a/gbdk-lib/libc/asm/z80/__ltoa.s b/gbdk-lib/libc/asm/z80/__ltoa.s @@ -0,0 +1,254 @@ +;-------------------------------------------------------------------------- +; __ltoa.s +; +; Copyright (C) 2020, Sergey Belyashov +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___ltoa + .globl ___ultoa +; +;void __itoa(long value, char *string, unsigned char radix); +; +___ltoa:: + push ix + ld ix, #0 + add ix, sp +; +; 4(ix) - value +; 8(ix) - string +; 10(ix) - radix +; + ld e, 4 (ix) + ld d, 5 (ix) + bit 7, 7 (ix) + jr Z, ___ultoa_de +;positive/negative numbers are supported only for radix=10 + ld a, 10 (ix) + cp a, #10 + jr NZ, ___ultoa_de +;add minus sign to result and inverse value + ld hl, #0 + or a, a + sbc hl, de + ex de, hl + ld hl, #0 + ld c, 6 (ix) + ld b, 7 (ix) + sbc hl, bc + ld 6 (ix), l + ld 7 (ix), h + ld l, 8 (ix) + ld h, 9 (ix) + ld (hl), #0x2D ;minus symbol + inc hl + ld 8 (ix), l + ld 9 (ix), h + jr ___ultoa_dehl +; +;void __uitoa(unsigned int value, char *string, unsigned char radix); +; +___ultoa:: + push ix + ld ix, #0 + add ix, sp +; +; 4(ix) - value +; 8(ix) - string +; 10(ix) - radix +; + ld e, 4 (ix) + ld d, 5 (ix) +; +___ultoa_de: + ld l, 8 (ix) + ld h, 9 (ix) +; +___ultoa_dehl: + ld a, e + or a, d + or a, 6 (ix) + or a, 7 (ix) + jr NZ, 100$ +; + ld (hl), #0x30 + inc hl + jp 190$ +100$: + ld a, 10 (ix) + cp a, #10 ;most popular radix + jr NZ, 110$ +; +;-------- decimal convertion +;this algorithm is 20% faster than generic one +; + ld c, l + ld b, h + ld hl, #-5 + add hl, sp + ld sp, hl + push bc + push hl + ld c, 6 (ix) + ld b, 7 (ix) + push bc + push de + call ___ultobcd + ld hl, #6 + add hl, sp + ld sp, hl + pop de ;DE - pointer to string + inc hl + inc hl ;HL - pointer to BCD value + ld b, #5 ;number of bytes in BCD value + ld a, #0x30 ;ASCII code of '0' +103$: + rrd + ld (de), a + inc de + rrd + ld (de), a + inc de + inc hl + djnz 103$ +; +; ld sp, hl +;skip trailing zeroes + ld b, #10 ;real decimal number is at most 10 digits +105$: + dec de + ld a, (de) + cp a, #0x30 + jr NZ, 107$ ;break loop if non-zero found + djnz 105$ +107$: + inc de ;always point to symbol next to last significant + ex de, hl + jr 190$ +; +;--------------------------- +; +110$: + cp a, #2 + jr C, 190$ ;radix is less than 2 +; + ld c, a + dec c + and a, c + jr NZ, 150$ +; +;-------- radix is power of 2 +; +; DE - lower 16 bits of value, HL - pointer to string, C - mask +120$: + ld a, e + ld b, c +125$: + srl 7 (ix) + rr 6 (ix) + rr d + rr e + srl b + jr NZ, 125$ +; + and a, c + add a, #0x30 + cp a, #0x3A ;convert to 0...9A...Z + jr C, 130$ + add a, #7 +130$: + ld (hl), a + inc hl + ld a, e + or a, d + or a, 6 (ix) + or a, 7 (ix) + jr NZ, 120$ + jr 190$ +; +;--------------------------- +; +;-------- custom radix (generic algorithm) +; +150$: + ex de, hl + ld c, e + ld b, d + ld e, 6 (ix) + ld d, 7 (ix) +160$: + push bc + ld c, 10 (ix) + call ___divu32_8 + pop bc + add a, #0x30 + cp a, #0x3A + jr C, 165$ + add a, #7 +165$: + ld (bc), a + inc bc + ld a, l + or a, h + or a, e + or a, d + jr NZ, 160$ + ld l, c + ld h, b +; jr 190$ +; +;--------------------------- +; +;-------- finish string and reverse order +190$: + ld (hl), #0 + ld e, 8 (ix) + ld d, 9 (ix) + call ___strreverse_reg + ld sp, ix + pop ix + ret +; +;in: DEHL - divident, C - divisor +;out: DEHL - quotient, A - remainder +___divu32_8: + xor a, a + ld b, #32 +100$: + add hl, hl + rl e + rl d + rla + jr c, 110$ + cp a, c + jr c, 120$ +110$: + sub a, c + inc l +120$: + djnz 100$ + ret + diff --git a/gbdk-lib/libc/asm/z80/__sdcc_call_hl.s b/gbdk-lib/libc/asm/z80/__sdcc_call_hl.s @@ -0,0 +1,37 @@ +;-------------------------------------------------------------------------- +; crtcall.s +; +; Copyright (C) 2011, Maarten Brock +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___sdcc_call_hl + +; The Z80 has the jp (hl) instruction, which is perfect for implementing function pointers. + +___sdcc_call_hl: + jp (hl) + diff --git a/gbdk-lib/libc/asm/z80/__sdcc_call_iy.s b/gbdk-lib/libc/asm/z80/__sdcc_call_iy.s @@ -0,0 +1,37 @@ +;-------------------------------------------------------------------------- +; crtcall.s +; +; Copyright (C) 2011, Maarten Brock, 2015 Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___sdcc_call_iy + +; The Z80 has the jp (iy) instruction, which is perfect for implementing function pointers. + +___sdcc_call_iy: + jp (iy) + diff --git a/gbdk-lib/libc/asm/z80/__sdcc_critical.s b/gbdk-lib/libc/asm/z80/__sdcc_critical.s @@ -0,0 +1,54 @@ +;-------------------------------------------------------------------------- +; __sdcc_critical.s +; +; Copyright (C) 2020, Sergey Belyashov +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___sdcc_critical_enter +; +; NMOS Z80 compatible +; this function cannot be placed at 0x0000...0x00ff addresses +; +___sdcc_critical_enter:: + xor a, a + push af + pop af + ld a, i + di + ret pe ;enabled interrupts + dec sp + dec sp + pop af + or a, a ;A = 0 if interrupts disabled + jr NZ, 00100$ +;inetrrupts disabled + sub a, a ;force P/V = 0 + ret +;interrupts enabled +00100$: + xor a, a ;force P/V = 1 + ret diff --git a/gbdk-lib/libc/asm/z80/__strreverse.s b/gbdk-lib/libc/asm/z80/__strreverse.s @@ -0,0 +1,61 @@ +;-------------------------------------------------------------------------- +; __strreverse.s +; +; Copyright (C) 2020, Sergey Belyashov +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___strreverse + .globl ___strreverse_reg +; +;void __reverse(char *beg, char *end); +; +___strreverse:: + pop bc + pop de + pop hl + push hl + push de + push bc +; +;in: HL - pointer to end of string (null symbol), DE - pointer to start of string +; +___strreverse_reg:: + jr 110$ +100$: + add hl, de + ld a, (de) + ld c, (hl) + ld (hl), a + ld a, c + ld (de), a + inc de +110$: + dec hl + or a, a + sbc hl, de + jr NC, 100$ + ret diff --git a/gbdk-lib/libc/asm/z80/__uitobcd.s b/gbdk-lib/libc/asm/z80/__uitobcd.s @@ -0,0 +1,87 @@ +;-------------------------------------------------------------------------- +; __uitobcd.s +; +; Copyright (C) 2020, Sergey Belyashov +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___uitobcd +; +; void __uitobcd (unsigned int v, unsigned char bcd[3]) +; __uitobcd converts v to BCD representation to the bcd. +; bcd[] will contain BCD value. +; +___uitobcd: + push ix + ld ix, #0 + add ix, sp +; + ld bc, #0x1000 + ld d, c + ld e, c + ld l, 4 (ix) + ld h, 5 (ix) +; +;--- begin speed optimization +; + ld a, h + or a, a + jr NZ, 100$ +; + ld h, l + srl b +; +;--- end speed optimization +; +; HL - binary value +; CDE - future BCD value +; B - bits count (16) +100$: + add hl, hl + ld a, e + adc a, a + daa + ld e, a + ld a, d + adc a, a + daa + ld d, a + ld a, c + adc a, a + daa + ld c, a + djnz 100$ +; + ld l, 6 (ix) + ld h, 7 (ix) + ld (hl), e + inc hl + ld (hl), d + inc hl + ld (hl), c +; + pop ix + ret diff --git a/gbdk-lib/libc/asm/z80/__ultobcd.s b/gbdk-lib/libc/asm/z80/__ultobcd.s @@ -0,0 +1,122 @@ +;-------------------------------------------------------------------------- +; __ultobcd.s +; +; Copyright (C) 2020, Sergey Belyashov +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___ultobcd +; +; void __ultobcd (unsigned long v, unsigned char bcd[5]) +; __ultobcd converts v to BCD representation to the bcd. +; bcd[] will contain BCD value. +; +___ultobcd: + push ix + ld ix, #0 + add ix, sp + ld bc, #0x2000 +; +;--- begin speed optimization +; + ld l, 4 (ix) + ld h, 5 (ix) + ld e, 6 (ix) + ld d, 7 (ix) + ld a, e + or a, d + jr NZ, 101$ +;high 2 bytes are zero + ld b, #0x10 + ex de, hl +101$: + ld a, d + or a, a + jr NZ, 102$ +;high byte is zero + ld d, e + ld e, h + ld h, l + ld a, #-8 + add a, b + ld b, a +102$: + ld 4 (ix), l + ld 5 (ix), h + ld 6 (ix), e + ld 7 (ix), d +; +;--- end speed optimization +; + ld hl, #0x0000 + ld e, l + ld d, h +; (ix+0)..(ix+3) - binary value +; CDEHL - future BCD value +; B - bits count (32) +103$: + sla 4 (ix) + rl 5 (ix) + rl 6 (ix) + rl 7 (ix) + ld a, l + adc a, a + daa + ld l, a + ld a, h + adc a, a + daa + ld h, a + ld a, e + adc a, a + daa + ld e, a + ld a, d + adc a, a + daa + ld d, a + ld a, c + adc a, a + daa + ld c, a + djnz 103$ +; + ld b, l + ld a, h + ld l, 8 (ix) + ld h, 9 (ix) + ld (hl), b + inc hl + ld (hl), a + inc hl + ld (hl), e + inc hl + ld (hl), d + inc hl + ld (hl), c +; + pop ix + ret diff --git a/gbdk-lib/libc/asm/z80/abs.s b/gbdk-lib/libc/asm/z80/abs.s @@ -0,0 +1,61 @@ +;-------------------------------------------------------------------------- +; abs.s +; +; Copyright (C) 2010, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl _abs + +; 12B; 86T for nonnegative arguments, 78T for negative. +_abs: + pop hl + pop de + push de + push hl + xor a, a + ld l, a + ld h, a + sbc hl, de + ret P + ex de, hl + ret + +; 14B; 59T for nonegative arguments, 94T for negative: +;_abs: +; pop de +; pop hl +; push hl +; push de +; bit 7, h +; ret Z +; xor a, a +; ld e, a +; ld d, a +; ex de, hl +; sbc hl, de +; ret + diff --git a/gbdk-lib/libc/asm/z80/atomic_flag_test_and_set.s b/gbdk-lib/libc/asm/z80/atomic_flag_test_and_set.s @@ -0,0 +1,44 @@ +;-------------------------------------------------------------------------- +; atomic_flag_test_and_set.s +; +; Copyright (C) 2020, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl _atomic_flag_test_and_set + +_atomic_flag_test_and_set: + pop de + pop hl + push hl + push de + xor a, a + srl (hl) + ccf + rla + ld l, a + ret + diff --git a/gbdk-lib/libc/asm/z80/crtenter.s b/gbdk-lib/libc/asm/z80/crtenter.s @@ -0,0 +1,41 @@ +;-------------------------------------------------------------------------- +; crtenter.s +; +; Copyright (C) 2015, Alan Cox, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___sdcc_enter_ix + +; Factor out some start of function code to reduce code size + +___sdcc_enter_ix: + pop hl ; return address + push ix ; save frame pointer + ld ix, #0 + add ix, sp ; set ix to the stack frame + jp (hl) ; and return + diff --git a/gbdk-lib/libc/asm/z80/divmixed.s b/gbdk-lib/libc/asm/z80/divmixed.s @@ -0,0 +1,58 @@ +;-------------------------------------------------------------------------- +; divmixed.s +; +; Copyright (C) 2010, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + +.globl __divsuchar +.globl __divuschar + +__divsuchar: + ld hl, #2+1 + add hl, sp + + ld e, (hl) + dec hl + ld l, (hl) + ld h, #0 + + jp __div_signexte + +__divuschar: + ld hl, #2+1 + ld d, h + add hl, sp + + ld e, (hl) + dec hl + ld l, (hl) + + ld a, l ; Sign extend + rlca + sbc a, a + ld h, a + + jp __div16 + diff --git a/gbdk-lib/libc/asm/z80/divsigned.s b/gbdk-lib/libc/asm/z80/divsigned.s @@ -0,0 +1,137 @@ +;-------------------------------------------------------------------------- +; divsigned.s +; +; Copyright (C) 2000-2010, Michael Hope, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + +.area _CODE + +.globl __divsint +.globl __divschar + +__divsint: + pop af + pop hl + pop de + push de + push hl + push af + + jp __div16 + +__divschar: + ld hl, #2+1 + add hl, sp + + ld e, (hl) + dec hl + ld l, (hl) + +__div8:: + ld a, l ; Sign extend + rlca + sbc a,a + ld h, a +__div_signexte:: + ld a, e ; Sign extend + rlca + sbc a,a + ld d, a + ; Fall through to __div16 + + ;; signed 16-bit division + ;; + ;; Entry conditions + ;; HL = dividend + ;; DE = divisor + ;; + ;; Exit conditions + ;; HL = quotient + ;; DE = remainder + ;; + ;; Register used: AF,B,DE,HL +__div16:: + ;; Determine sign of quotient by xor-ing high bytes of dividend + ;; and divisor. Quotient is positive if signs are the same, negative + ;; if signs are different + ;; Remainder has same sign as dividend + ld a, h ; Get high byte of dividend + xor a, d ; Xor with high byte of divisor + rla ; Sign of quotient goes into the carry + ld a, h ; Get high byte of dividend + push af ; Save sign of both quotient and reminder + + ; Take absolute value of dividend + rla + jr NC, .chkde ; Jump if dividend is positive + sub a, a ; Substract dividend from 0 + sub a, l + ld l, a + sbc a, a ; Propagate borrow (A=0xFF if borrow) + sub a, h + ld h, a + + ; Take absolute value of divisor +.chkde: + bit 7, d + jr Z, .dodiv ; Jump if divisor is positive + sub a, a ; Subtract divisor from 0 + sub a, e + ld e, a + sbc a, a ; Propagate borrow (A=0xFF if borrow) + sub a, d + ld d, a + + ; Divide absolute values +.dodiv: + call __divu16 + +.fix_quotient: + ; Negate quotient if it is negative + pop af ; recover sign of quotient + ret NC ; Jump if quotient is positive + ld b, a + sub a, a ; Subtract quotient from 0 + sub a, l + ld l, a + sbc a, a ; Propagate borrow (A=0xFF if borrow) + sub a, h + ld h, a + ld a, b + ret + +__get_remainder:: + ; Negate remainder if it is negative and move it into hl + rla + ex de, hl + ret NC ; Return if remainder is positive + sub a, a ; Subtract remainder from 0 + sub a, l + ld l, a + sbc a, a ; Propagate remainder (A=0xFF if borrow) + sub a, h + ld h, a + ret + diff --git a/gbdk-lib/libc/asm/z80/divunsigned.s b/gbdk-lib/libc/asm/z80/divunsigned.s @@ -0,0 +1,143 @@ +;-------------------------------------------------------------------------- +; divunsigned.s +; +; Copyright (C) 2000-2012, Michael Hope, Philipp Klaus Krause, Marco Bodrato +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + ;; Originally from GBDK by Pascal Felber. + +.area _CODE + +.globl __divuint +.globl __divuchar + +__divuint: + pop af + pop hl + pop de + push de + push hl + push af + + jr __divu16 + +__divuchar: + ld hl,#2+1 + add hl,sp + + ld e,(hl) + dec hl + ld l,(hl) + + ;; Fall through +__divu8:: + ld h,#0x00 + ld d,h + ; Fall through to __divu16 + + ;; unsigned 16-bit division + ;; + ;; Entry conditions + ;; HL = dividend + ;; DE = divisor + ;; + ;; Exit conditions + ;; HL = quotient + ;; DE = remainder + ;; carry = 0 + ;; If divisor is 0, quotient is set to "infinity", i.e HL = 0xFFFF. + ;; + ;; Register used: AF,B,DE,HL +__divu16:: + ;; Two algorithms: one assumes divisor <2^7, the second + ;; assumes divisor >=2^7; choose the applicable one. + ld a,e + and a,#0x80 + or a,d + jr NZ,.morethan7bits + ;; Both algorithms "rotate" 24 bits (H,L,A) but roles change. + + ;; unsigned 16/7-bit division +.atmost7bits: + ld b,#16 ; bits in dividend and possible quotient + ;; Carry cleared by AND/OR, this "0" bit will pass trough HL.[*] + adc hl,hl +.dvloop7: + ;; HL holds both dividend and quotient. While we shift a bit from + ;; MSB of dividend, we shift next bit of quotient in from carry. + ;; A holds remainder. + rla + + ;; If remainder is >= divisor, next bit of quotient is 1. We try + ;; to compute the difference. + sub a,e + jr NC,.nodrop7 ; Jump if remainder is >= dividend + add a,e ; Otherwise, restore remainder + ;; The add above sets the carry, because sbc a,e did set it. +.nodrop7: + ccf ; Complement borrow so 1 indicates a + ; successful substraction (this is the + ; next bit of quotient) + adc hl,hl + djnz .dvloop7 + ;; Carry now contains the same value it contained before + ;; entering .dvloop7[*]: "0" = valid result. + ld e,a ; DE = remainder, HL = quotient + ret + +.morethan7bits: + ld b,#9 ; at most 9 bits in quotient. + ld a,l ; precompute the first 7 shifts, by + ld l,h ; doing 8 + ld h,#0 + rr l ; undoing 1 +.dvloop: + ;; Shift next bit of quotient into bit 0 of dividend + ;; Shift next MSB of dividend into LSB of remainder + ;; A holds both dividend and quotient. While we shift a bit from + ;; MSB of dividend, we shift next bit of quotient in from carry + ;; HL holds remainder + adc hl,hl ; HL < 2^(7+9), no carry, ever. + + ;; If remainder is >= divisor, next bit of quotient is 1. We try + ;; to compute the difference. + sbc hl,de + jr NC,.nodrop ; Jump if remainder is >= dividend + add hl,de ; Otherwise, restore remainder + ;; The add above sets the carry, because sbc hl,de did set it. +.nodrop: + ccf ; Complement borrow so 1 indicates a + ; successful substraction (this is the + ; next bit of quotient) + rla + djnz .dvloop + ;; Take care of the ninth quotient bit! after the loop B=0. + rl b ; BA = quotient + ;; Carry now contains "0" = valid result. + ld d,b + ld e,a ; DE = quotient, HL = remainder + ex de,hl ; HL = quotient, DE = remainder + ret + diff --git a/gbdk-lib/libc/asm/z80/heap.s b/gbdk-lib/libc/asm/z80/heap.s @@ -0,0 +1,44 @@ +;-------------------------------------------------------------------------- +; heap.s +; +; Copyright (C) 2001, Michael Hope +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + +; Just stubs - not copyrightable + + ;; Stubs that hook the heap in + .globl ___sdcc_heap_init + + .area _GSINIT + call ___sdcc_heap_init + + .area _HEAP +___sdcc_heap:: + ;; For now just allocate 1k of heap. + .ds 1023 + + .area _HEAP_END +___sdcc_heap_end:: + .ds 1 diff --git a/gbdk-lib/libc/asm/z80/memcpy.s b/gbdk-lib/libc/asm/z80/memcpy.s @@ -0,0 +1,53 @@ +;-------------------------------------------------------------------------- +; memcpy.s +; +; Copyright (C) 2020, Sergey Belyashov +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl _memcpy + .globl ___memcpy + +; The Z80 has the ldir instruction, which is perfect for implementing memcpy(). +_memcpy: +___memcpy: + pop af + pop hl ;return value expected to be in HL, so pop dst to HL + pop de + pop bc + push bc + push de + push hl + push af + ld a, c + or a, b + ret Z + push hl + ex de, hl + ldir + pop hl + ret + diff --git a/gbdk-lib/libc/asm/z80/memmove.s b/gbdk-lib/libc/asm/z80/memmove.s @@ -0,0 +1,65 @@ +;-------------------------------------------------------------------------- +; memmove.s +; +; Copyright (C) 2008-2009, Philipp Klaus Krause, Marco Bodrato +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl _memmove + +; The Z80 has the ldir and lddr instructions, which are perfect for implementing memmove(). + +_memmove: + pop af + pop hl + pop de + pop bc + push bc + push de + push hl + push af + ld a, c + or a, b + ret Z + push hl + sbc hl, de ; or above cleared carry. + add hl, de ; same carry as the line before + jr C, memmove_up +memmove_down: + dec bc + add hl, bc + ex de, hl + add hl, bc + inc bc + lddr + pop hl + ret +memmove_up: + ex de, hl + ldir + pop hl + ret + diff --git a/gbdk-lib/libc/asm/z80/modmixed.s b/gbdk-lib/libc/asm/z80/modmixed.s @@ -0,0 +1,62 @@ +;-------------------------------------------------------------------------- +; modmixed.s +; +; Copyright (C) 2010, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + +.globl __modsuchar +.globl __moduschar + +__modsuchar: + ld hl,#2+1 + add hl,sp + + ld e,(hl) + dec hl + ld l,(hl) + ld h,#0 + + call __div_signexte + + jp __get_remainder + +__moduschar: + ld hl,#2+1 + ld d, h + add hl,sp + + ld e,(hl) + dec hl + ld l,(hl) + + ld a,l ; Sign extend + rlca + sbc a, a + ld h, a + + call __div16 + + jp __get_remainder + diff --git a/gbdk-lib/libc/asm/z80/modsigned.s b/gbdk-lib/libc/asm/z80/modsigned.s @@ -0,0 +1,57 @@ +;-------------------------------------------------------------------------- +; modsigned.s +; +; Copyright (C) 2009, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + +.area _CODE + +.globl __modschar +.globl __modsint + +__modschar: + ld hl,#2+1 + add hl,sp + + ld e,(hl) + dec hl + ld l,(hl) + + call __div8 + + jp __get_remainder + +__modsint: + pop af + pop hl + pop de + push de + push hl + push af + + call __div16 + + jp __get_remainder + diff --git a/gbdk-lib/libc/asm/z80/modunsigned.s b/gbdk-lib/libc/asm/z80/modunsigned.s @@ -0,0 +1,61 @@ +;-------------------------------------------------------------------------- +; modunsigned.s +; +; Copyright (C) 2009-2010, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + +.area _CODE + +.globl __moduchar +.globl __moduint + +__moduchar: + ld hl,#2+1 + add hl,sp + + ld e,(hl) + dec hl + ld l,(hl) + + call __divu8 + + ex de,hl + + ret + +__moduint: + pop af + pop hl + pop de + push de + push hl + push af + + call __divu16 + + ex de,hl + + ret + diff --git a/gbdk-lib/libc/asm/z80/mul.s b/gbdk-lib/libc/asm/z80/mul.s @@ -0,0 +1,74 @@ +;-------------------------------------------------------------------------- +; mulchar.s +; +; Copyright (C) 2000, Michael Hope +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + +.area _CODE + +.globl __mulint + +__mulint: + pop af + pop bc + pop de + push de + push bc + push af + + ;; 16-bit multiplication + ;; + ;; Entry conditions + ;; bc = multiplicand + ;; de = multiplier + ;; + ;; Exit conditions + ;; hl = less significant word of product + ;; + ;; Register used: AF,BC,DE,HL +__mul16:: + xor a,a + ld l,a + or a,b + ld b,#16 + + ;; Optimise for the case when this side has 8 bits of data or + ;; less. This is often the case with support address calls. + jr NZ,2$ + ld b,#8 + ld a,c +1$: + ;; Taken from z88dk, which originally borrowed from the + ;; Spectrum rom. + add hl,hl +2$: + rl c + rla ;DLE 27/11/98 + jr NC,3$ + add hl,de +3$: + djnz 1$ + ret + diff --git a/gbdk-lib/libc/asm/z80/mulchar.s b/gbdk-lib/libc/asm/z80/mulchar.s @@ -0,0 +1,79 @@ +;-------------------------------------------------------------------------- +; mulchar.s +; +; Copyright (c) 2017, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + +.area _CODE + +; unsigned char x unsigned char multiplication is done by code generation. + +.globl __mulsuchar +.globl __muluschar +.globl __mulschar + +; operands have different sign + +__mulsuchar: + ld hl,#2+1 + ld b, h + add hl,sp + + ld e,(hl) + dec hl + ld c,(hl) + jr signexte + +__muluschar: + ld hl,#2 + ld b, h + add hl,sp + + ld e,(hl) + inc hl + ld c,(hl) + jr signexte + +__mulschar: + ld hl,#2+1 + add hl,sp + + ld e,(hl) + dec hl + ld c,(hl) + + ;; Need to sign extend before going in. + ld a,c + rla + sbc a,a + ld b,a +signexte: + ld a,e + rla + sbc a,a + ld d,a + + jp __mul16 + diff --git a/gbdk-lib/libc/asm/z80/setjmp.s b/gbdk-lib/libc/asm/z80/setjmp.s @@ -0,0 +1,95 @@ +;-------------------------------------------------------------------------- +; setjmp.s +; +; Copyright (C) 2011-2014, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl ___setjmp + +___setjmp: + pop hl + pop iy + push af + push hl + + ; Store return address. + ld 0(iy), l + ld 1(iy), h + + ; Store stack pointer. + xor a, a + ld l, a + ld h, a + add hl, sp + ld 2(iy), l + ld 3(iy), h + + ; Store frame pointer. + push ix + pop hl + ld 4(iy), l + ld 5(iy), h + + ; Return 0. + ld l, a + ld h, a + ret + +.globl _longjmp + +_longjmp: + pop af + pop iy + pop de + + ; Ensure that return value is non-zero. + ld a, e + or a, d + jr NZ, jump + inc de +jump: + + ; Restore frame pointer. + ld l, 4(iy) + ld h, 5(iy) + push hl + pop ix + + ; Adjust stack pointer. + ld l, 2(iy) + ld h, 3(iy) + ld sp, hl + pop hl + + ; Move return value into hl. + ex de, hl + + ; Jump. + ld c, 0(iy) + ld b, 1(iy) + push bc + ret diff --git a/gbdk-lib/libc/asm/z80/strcpy.s b/gbdk-lib/libc/asm/z80/strcpy.s @@ -0,0 +1,48 @@ +;-------------------------------------------------------------------------- +; strcpy.s +; +; Copyright (C) 2012, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl _strcpy + +_strcpy: + pop bc + pop de + pop hl + push hl + push de + push bc + push de + xor a, a +loop: + cp a, (hl) + ldi + jr NZ, loop + pop hl + ret + diff --git a/gbdk-lib/libc/asm/z80/strlen.s b/gbdk-lib/libc/asm/z80/strlen.s @@ -0,0 +1,47 @@ +;-------------------------------------------------------------------------- +; strlen.s +; +; Copyright (C) 2008-2009, Philipp Klaus Krause +; +; This library is free software; you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) any +; later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this library; see the file COPYING. If not, write to the +; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, +; MA 02110-1301, USA. +; +; As a special exception, if you link this library with other files, +; some of which are compiled with SDCC, to produce an executable, +; this library does not by itself cause the resulting executable to +; be covered by the GNU General Public License. This exception does +; not however invalidate any other reasons why the executable file +; might be covered by the GNU General Public License. +;-------------------------------------------------------------------------- + + .area _CODE + + .globl _strlen + +; The Z80 has the cpir instruction, which is perfect for implementing strlen(). + +_strlen: + pop bc + pop hl + push hl + push bc + xor a, a + ld b, a + ld c, a + cpir + ld hl, #-1 + sbc hl, bc ; C flag still cleared from xor above. + ret + diff --git a/gbdk-lib/libc/bcd.c b/gbdk-lib/libc/bcd.c @@ -1,220 +0,0 @@ -#include <stdint.h> -#include "bcd.h" - -void uint2bcd(uint16_t i, BCD * value) __naked -{ - i; value; // suppress warninig: unreferenced function argument -__asm - lda HL, 2(SP) - ld A, (HL+) ; DE: uint - ld E, A - ld A, (HL+) - ld D, A - ld A, (HL+) - ld H, (HL) - ld L, A ; HL: dest - - push BC - - ; clear value - xor A - ld BC, #-4 - - ld (HL+), A - ld (HL+), A - ld (HL+), A - ld (HL+), A - add HL, BC - - ld B, #16 -1$: - sla E - rl D - - ld A, (HL) - adc A - daa - ld (HL+), A - ld A, (HL) - adc A - daa - ld (HL+), A - ld A, (HL) - adc A - daa - ld (HL-), A - - dec HL - - dec B - jr NZ, 1$ - - pop BC - ret -__endasm; -} - -void bcd_add(BCD * sour, BCD * value) __naked -{ - sour; value; // suppress warninig: unreferenced function argument -__asm - lda HL, 5(SP) - ld D, (HL) - dec HL - ld E, (HL) ; DE: value - dec HL - ld A, (HL-) - ld L, (HL) - ld H, A ; HL: sour - - or A ; clear C, HC - - ld A,(DE) - add (HL) - daa - ld (HL+), A - inc DE - - ld A,(DE) - adc (HL) - daa - ld (HL+), A - inc DE - - ld A,(DE) - adc (HL) - daa - ld (HL+), A - inc DE - - ld A,(DE) - adc (HL) - daa - ld (HL+), A - - ret -__endasm; -} - -void bcd_sub(BCD * sour, BCD * value) __naked -{ - sour; value; // suppress warninig: unreferenced function argument -__asm - lda HL, 2(SP) - ld E, (HL) - inc HL - ld D, (HL) ; DE: sour - inc HL - ld A, (HL+) - ld H, (HL) - ld L, A ; HL: value - - or A ; clear C, HC - - ld A,(DE) - sub (HL) - daa - ld (DE), A - inc DE - inc HL - - ld A,(DE) - sbc (HL) - daa - ld (DE), A - inc DE - inc HL - - ld A,(DE) - sbc (HL) - daa - ld (DE), A - inc DE - inc HL - - ld A,(DE) - sbc (HL) - daa - ld (DE), A - - ret -__endasm; -} - -uint8_t bcd2text(BCD * bcd, uint8_t tile_offset, uint8_t * buffer) __naked -{ - bcd; tile_offset; buffer; -__asm - push BC - - lda HL, 4(SP) - ld E, (HL) - inc HL - ld D, (HL) ; DE: bcd - inc HL - ld C, (HL) ; C: digit offset - inc HL - ld A, (HL+) - ld H, (HL) - ld L, A ; HL: buffer - - inc DE - inc DE - inc DE - - ld B, #0x0f - - ld A, (DE) - swap A - and B - add C - ld (HL+), A - ld A, (DE) - and B - add C - ld (HL+), A - dec DE - - ld A, (DE) - swap A - and B - add C - ld (HL+), A - ld A, (DE) - and B - add C - ld (HL+), A - dec DE - - ld A, (DE) - swap A - and B - add C - ld (HL+), A - ld A, (DE) - and B - add C - ld (HL+), A - dec DE - - ld A, (DE) - swap A - and B - add C - ld (HL+), A - ld A, (DE) - and B - add C - ld (HL+), A - dec DE - - xor A - ld (HL+), A - - ld D, A - ld E, #0x08 - - pop BC - ret -__endasm; -} diff --git a/gbdk-lib/libc/gb/Makefile b/gbdk-lib/libc/gb/Makefile @@ -1,56 +0,0 @@ -# GB specific Makefile - -TOPDIR = ../.. - -THIS = gb -PORT = gbz80 - -CSRC = digits.c gprint.c gprintf.c gprintln.c gprintn.c - -ASSRC = cgb.s cgb_palettes.s cgb_compat.s \ - cpy_data.s \ - drawing.s drawing_isr.s color.s \ - f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \ - get_bk_t.s get_data.s get_tile.s \ - get_wi_t.s get_xy_t.s global.s \ - get_addr.s \ - hiramcpy.s init_tt.s input.s \ - pad.s sample.s \ - serial.s set_bk_t.s set_tile.s \ - set_data.s set_prop.s set_spr.s set_wi_t.s set_xy_t.s \ - set_1bit_data.s \ - sgb.s font.s delay.s \ - rand.s arand.s \ - bgb_emu.s bgb_emu_printf.s \ - nowait.s far_ptr.s \ - lcd.s joy.s tim.s \ - crash_handler.s \ - ___sdcc_bcall_ehl.s ___sdcc_bcall.s \ - mv_spr.s \ - pad_ex.s \ - mode.s clock.s \ - get_t.s set_t.s init_vram.s \ - fill_rect.s fill_rect_bk.s fill_rect_wi.s \ - metasprites.s metasprites_flip.s metasprites_hide.s metasprites_hide_spr.s \ - set_tile_submap.s set_win_tile_submap.s \ - gb_decompress.s gb_decompress_tiles.s \ - heap.s \ - crt0.s - -ifeq ($(ASM),asxxxx) -ASSRC += sfr.s -endif -ifeq ($(ASM),rgbds) -ASSRC += stubs.s -endif - -CRT0 = crt0.s - -include $(TOPDIR)/Makefile.common - -AS = $(AS_GBZ80) - -include ../Makefile.platform - -#OBJ = crt0.o putchar.o font.o ibmfixed.o drawing.o init_tt.o \ -# cpy_data.o diff --git a/gbdk-lib/libc/gb/arand.s b/gbdk-lib/libc/gb/arand.s @@ -1,129 +0,0 @@ -;/*************************************************************************** -; * * -; * Module : arand.s * -; * * -; * Purpose : A random number generator using the lagged additive method * -; * * -; * Version : 1, January 11 1998 * -; * * -; * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) * -; * * -; **************************************************************************/ - - ;; BANKED: checked - .include "global.s" - - .globl .initrand - .globl _rand - - .area _BSS -.start_arand_vars: - -.randarr: - .ds 55 -.raxj: - .ds 0x01 -.raxk: - .ds 0x01 - -.end_arand_vars: - - .area _GSINIT - - XOR A - LD HL,#.start_arand_vars - LD C,#(.end_arand_vars - .start_arand_vars) - RST 0x28 - - .area _CODE - - ;; arand() operates on an array of 55 arbitrary values (here : bytes). - ;; It adds two values of the array together, replaces one of the values - ;; with the result, and returns the result. - ;; At start, the indices into the array refer to the 55th and 24th element. - ;; After each call, each index is decreased, and looped around if necessary. - ;; This kind of works, but the values produces are less good than those by - ;; rand(), mainly because it operates on bytes instead of words. - ;; Ref : D. E. Knuth, "The Art of Computer Programming" , Volume 2 - ;; - ;; Exit conditions - ;; DE = Random number (byte!) - ;; - ;; Registers used: - ;; all - ;; -_arand:: ; Banked - PUSH BC - LD D,#0 - LD HL,#.randarr-1 - LD A,(.raxj) - LD E,A - DEC A ; Decrease the pointer - JR NZ,1$ - LD A,#55 -1$: - LD (.raxj),A - ADD HL,DE - LD B,(HL) - - LD HL,#.randarr-1 ; Ooh... - LD A,(.raxk) - LD E,A - DEC A ; Decrease the pointer - JR NZ,2$ - LD A,#55 -2$: - LD (.raxk),A - ADD HL,DE - LD A,(HL) - - ADD B - LD (HL),A ; Store new value - - POP BC - - LD D,#0 - LD E,A - - RET - - ;; _initarand calls the _rand function to fill the array with random values - ;; Note that this also sets the seed value of the _rand function first, - ;; like _initrand - ;; - ;; Exit conditions - ;; None - ;; - ;; Registers used: - ;; all - ;; -_initarand:: ; Banked - LDA HL,.BANKOV(SP) - CALL .initrand - - PUSH BC - LD A,#55 - LD HL,#.randarr -1$: - DEC A - LD (.raxj),A - LD B,H - LD C,L - CALL _rand - LD H,B - LD L,C - - LD A, E - LD (HL+),A - - LD A,(.raxj) - CP #0 - JR NZ,1$ - - LD A,#24 ; Now the array has been filled,set the pointers - LD (.raxj),A - LD A,#55 - LD (.raxk),A - - POP BC - RET diff --git a/gbdk-lib/libc/gb/cgb_palettes.s b/gbdk-lib/libc/gb/cgb_palettes.s @@ -1,78 +0,0 @@ - .include "global.s" - - .title "CGB support" - .module CGB - - .area _CODE - -_set_sprite_palette:: ; Non-banked - PUSH BC - LD C,#.OCPS - JR .set_palette - -_set_bkg_palette:: ; Non-banked - PUSH BC - LD C,#.BCPS - -.set_palette:: - LDA HL,4(SP) ; Skip return address and registers - LD A,(HL+) ; first_palette - ADD A ; A *= 8 - ADD A - ADD A - OR #0x80 ; Set auto-increment - LDH (C),A - INC C - LD A,(HL+) ; D = nb_palettes - ADD A ; A *= 8 - ADD A - ADD A - LD B,A ; Number of bytes - LD A,(HL+) ; rgb_data - LD H,(HL) - LD L,A -1$: - WAIT_STAT - - LD A,(HL+) - LDH (C),A - DEC B - JR NZ,1$ - - POP BC - RET - -_set_sprite_palette_entry:: ; Banked - PUSH BC - LD C,#.OCPS - JR .set_palette_entry - -_set_bkg_palette_entry:: ; Banked - PUSH BC - LD C,#.BCPS - -.set_palette_entry:: - LDA HL,.BANKOV+2(SP); Skip return address and registers - LD A,(HL+) ; first_palette - ADD A ; A *= 4 - ADD A - LD B,A - LD A,(HL+) ; pal_entry - ADD B ; A += first_palette * 4 - ADD A ; A *= 2 - OR #0x80 ; Set auto-increment - LDH (C),A - INC C - LD A,(HL+) ; rgb_data - LD H,(HL) - LD L,A - - WAIT_STAT - - LD A,L - LDH (C),A - LD A,H - LDH (C),A - - POP BC - RET diff --git a/gbdk-lib/libc/gb/color.s b/gbdk-lib/libc/gb/color.s @@ -1,24 +0,0 @@ - .include "global.s" - - ;; Data - .area _BSS - ;; Foreground drawing colour -.fg_colour:: - .ds 1 - ;; Background drawing colour -.bg_colour:: - .ds 1 - ;; Drawing mode (.SOILD etc) -.draw_mode:: - .ds 1 - - .area _BASE -_color:: ; Banked - LDA HL,.BANKOV(SP) ; Skip return address and registers - LD A,(HL+) ; A = Foreground - LD (.fg_colour),a - LD A,(HL+) - LD (.bg_colour),a - LD A,(HL) - LD (.draw_mode),a - RET diff --git a/gbdk-lib/libc/gb/crt0.s b/gbdk-lib/libc/gb/crt0.s @@ -1,497 +0,0 @@ - .include "global.s" - - ;; **************************************** - ;; Beginning of module - ;; BANKED: checked - .title "Runtime" - .module Runtime - .area _HEADER (ABS) - - ;; RST vectors -; .org 0x00 ; Trap, utilized by crash_handler.h - -; .org 0x08 ; --profile handler utilized by bgb_emu.h - -; .org 0x10 ; empty - -; .org 0x18 ; empty - - .org 0x20 ; RST 0x20 == call HL -.call_hl:: - JP (HL) - - .org 0x28 ; zero up to 256 bytes in C pointed by HL -.MemsetSmall:: - LD (HL+),A - DEC C - JR NZ,.MemsetSmall - ret - - .org 0x30 ; copy up to 256 bytes in C from DE to HL -.MemcpySmall:: - LD A, (DE) - LD (HL+), A - INC DE - DEC C - JR NZ,.MemcpySmall - RET - -; .org 0x38 ; crash handler utilized by crash_handler.h - - ;; Hardware interrupt vectors - .org 0x40 ; VBL -.int_VBL: - PUSH AF - PUSH HL - LD HL,#.int_0x40 - JP .int - -; .org 0x48 ; LCD - -; .org 0x50 ; TIM - -; .org 0x58 ; SIO - -; .org 0x60 ; JOY - -; .org 0x70 - ;; space for drawing.s bit table - - .org 0x80 -.int:: - PUSH BC - PUSH DE -1$: - LD A,(HL+) - OR (HL) - JR Z,.int_tail - PUSH HL - LD A,(HL-) - LD L,(HL) - LD H,A - RST 0x20 ; .call_hl - POP HL - INC HL - JR 1$ -_wait_int_handler:: - ADD SP,#4 -.int_tail: - POP DE - POP BC - POP HL - - ;; we return at least at the beginning of mode 2 - WAIT_STAT - - POP AF - RETI - - ;; VBlank default interrupt routine -__standard_VBL_handler:: -.std_vbl: - LD HL,#.sys_time - INC (HL) - JR NZ,2$ - INC HL - INC (HL) -2$: - CALL .refresh_OAM - - LD A, #1 - LDH (.vbl_done),A - RET - - ;; GameBoy Header - - ;; DO NOT CHANGE... - .org 0x100 -.header: - JR .code_start - - ;; Nintendo logo - .org 0x104 - .byte 0xCE,0xED,0x66,0x66 - .byte 0xCC,0x0D,0x00,0x0B - .byte 0x03,0x73,0x00,0x83 - .byte 0x00,0x0C,0x00,0x0D - .byte 0x00,0x08,0x11,0x1F - .byte 0x88,0x89,0x00,0x0E - .byte 0xDC,0xCC,0x6E,0xE6 - .byte 0xDD,0xDD,0xD9,0x99 - .byte 0xBB,0xBB,0x67,0x63 - .byte 0x6E,0x0E,0xEC,0xCC - .byte 0xDD,0xDC,0x99,0x9F - .byte 0xBB,0xB9,0x33,0x3E - - ;; Title of the game - .org 0x134 - .asciz "Title" - - .org 0x144 - .byte 0,0,0 - - ;; Cartridge type is ROM only - .org 0x147 - .byte 0 - - ;; ROM size is 32kB - .org 0x148 - .byte 0 - - ;; RAM size is 0kB - .org 0x149 - .byte 0 - - ;; Maker ID - .org 0x14A - .byte 0x00,0x00 - - ;; Version number - .org 0x14C - .byte 0x01 - - ;; Complement check - .org 0x14D - .byte 0x00 - - ;; Checksum - .org 0x14E - .byte 0x00,0x00 - - ;; **************************************** - .org 0x150 - - ;; soft reset: falldown to .code_start -.reset:: -_reset:: - LD A,(__cpu) - - ;; Initialization code -.code_start:: - DI ; Disable interrupts - LD D,A ; Store CPU type in D - ;; Initialize the stack - LD SP,#.STACK - - LD A, #>_shadow_OAM - LDH (__shadow_OAM_base), A - LD H, A - XOR A - LD L, A - LD C, #(40 << 2) ; 40 entries 4 bytes each - RST 0x28 - - ;; Clear CRT0 global variables - LD HL,#.start_crt_globals - LD C,#(.end_crt_globals - .start_crt_globals) - RST 0x28 - -; LD (.mode),A ; Clearing (.mode) is performed when clearing RAM - - ;; Store CPU type - LD A,D - LD (__cpu),A - - ;; Turn the screen off - CALL .display_off - - XOR A - ;; Initialize the display - LDH (.SCY),A - LDH (.SCX),A - LDH (.STAT),A - LDH (.WY),A - LD A,#0x07 - LDH (.WX),A - - ;; Copy refresh_OAM routine to HRAM - LD DE,#.start_refresh_OAM ; source - LD HL,#.refresh_OAM ; dest - LD C,#(.end_refresh_OAM - .start_refresh_OAM) ; size - RST 0x30 ; call .MemcpySmall - - ;; Clear the OAM by calling refresh_OAM - CALL .refresh_OAM - - ;; Install interrupt routines - LD BC,#.std_vbl - CALL .add_VBL - - ;; Standard color palettes - LD A,#0b11100100 ; Grey 3 = 11 (Black) - ; Grey 2 = 10 (Dark grey) - ; Grey 1 = 01 (Light grey) - ; Grey 0 = 00 (Transparent) - LDH (.BGP),A - LDH (.OBP0),A - LD A,#0b00011011 - LDH (.OBP1),A - - ;; Turn the screen on - LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGOFF) - LDH (.LCDC),A - XOR A - LDH (.IF),A - LD A,#.VBL_IFLAG ; switch on VBlank interrupt only - LDH (.IE),A - - LDH (__current_bank),A ; current bank is 1 at startup - - XOR A - - LD HL,#.sys_time - LD (HL+),A - LD (HL),A - - LDH (.NR52),A ; Turn sound off - - CALL gsinit - - EI ; Enable interrupts - - ;; Call the main function - CALL _main -_exit:: -99$: - HALT - NOP - JR 99$ ; Wait forever - -_set_interrupts:: - DI - LDA HL,2(SP) ; Skip return address - XOR A - LDH (.IF),A ; Clear pending interrupts - LD A,(HL) - EI ; Enable interrupts - LDH (.IE),A ; interrupts are still disabled here - RET - - ;; Copy OAM data to OAM RAM -.start_refresh_OAM: - LDH A,(__shadow_OAM_base) - OR A - RET Z - - LDH (.DMA),A ; Put A into DMA registers - LD A,#0x28 ; We need to wait 160 ns -1$: - DEC A - JR NZ,1$ - RET -.end_refresh_OAM: - - .org .MODE_TABLE - ;; Jump table for modes - RET - - ;; **************************************** - - ;; Ordering of segments for the linker - ;; Code that really needs to be in bank 0 - .area _HOME - ;; Similar to _HOME - .area _BASE - ;; Code - .area _CODE - ;; #pragma bank 0 workaround - .area _CODE_0 - ;; Constant data - .area _LIT -; ;; since _CODE_1 area base address is pre-defined in the linker from 0x4000, -; ;; that moves initializer code and tables out of bank 0 -; .area _CODE_1 - ;; Constant data, used to init _DATA - .area _INITIALIZER - ;; Code, used to init _DATA - .area _GSINIT - .area _GSFINAL - ;; Uninitialised ram data - .area _DATA - .area _BSS - ;; Initialised in ram data - .area _INITIALIZED - ;; For malloc - .area _HEAP - - .area _BSS -.start_crt_globals: - -__cpu:: - .ds 0x01 ; GB type (GB, PGB, CGB) -.mode:: - .ds 0x01 ; Current mode -.sys_time:: -_sys_time:: - .ds 0x02 ; System time in VBL units -.int_0x40:: - .blkw 0x0A ; 4 interrupt handlers (built-in + user-defined) - -.end_crt_globals: - - .area _HRAM (ABS) - - .org 0xFF90 -__current_bank:: ; Current bank - .ds 0x01 -.vbl_done: - .ds 0x01 ; Is VBL interrupt finished? -__shadow_OAM_base:: - .ds 0x01 - - ;; Runtime library - .area _GSINIT -gsinit:: - LD DE, #l__INITIALIZER - LD A, D - OR E - JR Z, 4$ - LD HL, #s__INITIALIZED - LD BC, #s__INITIALIZER - - SRL D - RR E - JR NC,3$ - LD A,(BC) - LD (HL+),A - INC BC -3$: - INC D - INC E - JR 2$ -1$: - LD A,(BC) - LD (HL+),A - INC BC - LD A,(BC) - LD (HL+),A - INC BC -2$: - DEC E - JR NZ,1$ - DEC D - JR NZ,1$ -4$: - - .area _GSFINAL - ret - - .area _HOME - - ;; Remove interrupt routine in BC from the VBL interrupt list - ;; falldown to .remove_int -.remove_VBL:: - LD HL,#.int_0x40 - - ;; Remove interrupt BC from interrupt list HL if it exists - ;; Abort if a 0000 is found (end of list) -.remove_int:: -1$: - LD A,(HL+) - LD E,A - LD D,(HL) - INC HL - OR D - RET Z ; No interrupt found - - LD A,E - CP C - JR NZ,1$ - LD A,D - CP B - JR NZ,1$ - - LD D,H - LD E,L - DEC DE - DEC DE - - ;; Now do a memcpy from here until the end of the list -2$: - LD A,(HL+) - LD (DE),A - LD B,A - INC DE - LD A,(HL+) - LD (DE),A - INC DE - OR B - RET Z - JR 2$ - - ;; Add interrupt routine in BC to the VBL interrupt list - ;; falldown to .add_int -.add_VBL:: - LD HL,#.int_0x40 - - ;; Add interrupt routine in BC to the interrupt list in HL -.add_int:: -1$: - LD A,(HL+) - OR (HL) - JR Z,2$ - INC HL - JR 1$ -2$: - LD A,B - LD (HL-),A - LD (HL),C - RET - - ;; Wait for VBL interrupt to be finished -.wait_vbl_done:: -_wait_vbl_done:: - ;; Check if the screen is on - LDH A,(.LCDC) - AND #LCDCF_ON - RET Z ; Return if screen is off - XOR A - LDH (.vbl_done),A ; Clear any previous sets of vbl_done -1$: - HALT ; Wait for any interrupt - NOP ; HALT sometimes skips the next instruction - LDH A,(.vbl_done) ; Was it a VBlank interrupt? - ;; Warning: we may lose a VBlank interrupt, if it occurs now - OR A - JR Z,1$ ; No: back to sleep! - RET - -.display_off:: -_display_off:: - ;; Check if the screen is on - LDH A,(.LCDC) - AND #LCDCF_ON - RET Z ; Return if screen is off -1$: ; We wait for the *NEXT* VBL - LDH A,(.LY) - CP #0x92 ; Smaller than or equal to 0x91? - JR NC,1$ ; Loop until smaller than or equal to 0x91 -2$: - LDH A,(.LY) - CP #0x91 ; Bigger than 0x90? - JR C,2$ ; Loop until bigger than 0x90 - - LDH A,(.LCDC) - AND #~LCDCF_ON - LDH (.LCDC),A ; Turn off screen - RET - -_remove_VBL:: - PUSH BC - LDA HL,4(SP) ; Skip return address and registers - LD A,(HL+) - LD C,A - LD B,(HL) - CALL .remove_VBL - POP BC - RET - -_add_VBL:: - PUSH BC - LDA HL, 4(SP) ; Skip return address and registers - LD A,(HL+) - LD C,A - LD B,(HL) - CALL .add_VBL - POP BC - RET diff --git a/gbdk-lib/libc/gb/drawing.s b/gbdk-lib/libc/gb/drawing.s @@ -1,1771 +0,0 @@ -;; Optimised Drawing library -;; By Jon Fuge (jonny@q-continuum.demon.co.uk) based on original file -;; Updates -;; 990223 Michael Removed mod_col, splitting it up into -;; fg_colour, bg_colour, and draw_mode -;; Note: some optimisations are available with unneded PUSH DE/POP DE's - - ;; BANKED: checked - .include "global.s" - - .globl .init_vram - .globl .copy_vram - - .globl .drawing_lcd, .drawing_vbl - .globl .bg_colour, .fg_colour, .draw_mode - - .M_SOLID = 0x00 - .M_OR = 0x01 - .M_XOR = 0x02 - .M_AND = 0x03 - - ;; Format of mod_col - ;; 7 6 5 4 3 2 1 0 - ;; mode fg bg - - .area _DRAW_HEADER (ABS) - - .org 0x70 -.drawing_bits_tbl:: - .byte 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01 - .byte 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 - - .org .MODE_TABLE+4*.G_MODE - JP .gmode - - .module Drawing1 - - ;; Data - .area _BSS - ;; Fill style -.style: - .ds 0x01 - ;; Various varibles -.x_s: - .ds 2 -.y_s: - .ds 2 -.delta_x: - .ds 1 -.delta_y: - .ds 1 -.l_inc: - .ds 1 -.l_d: - .ds 2 -.dinc1: - .ds 2 -.dinc2: - .ds 2 -.tx: - .ds 1 -.ty: - .ds 1 - - .area _BASE - ;; Enter graphic mode -.gmode:: - DI ; Disable interrupts - - ;; Turn the screen off - LDH A,(.LCDC) - AND #LCDCF_ON - JR Z,1$ - - ;; Turn the screen off - CALL .display_off -1$: - LD HL,#0x8000+0x10*0x10 - LD DE,#0x1800-0x18*0x10 - LD B,#0x00 - CALL .init_vram ; Init the charset at 0x8000 - - ;; Install interrupt routines - LD BC,#.drawing_vbl - CALL .add_VBL - LD BC,#.drawing_lcd - CALL .add_LCD - - LD A,#72 ; Set line at which LCD interrupt occurs - LDH (.LYC),A - - LD A,#(STATF_LYC | STATF_LYCF) - LDH (.STAT),A - - LDH A,(.IE) - OR #.LCD_IFLAG ; Enable LCD interrupt - LDH (.IE),A - - ;; (9*20) = 180 tiles are used in the upper part of the screen - ;; (9*20) = 180 tiles are used in the lower part of the screen - ;; => We have 24 tiles free - ;; We keep 16 at 0x8000->0x80FF, and 8 at 0x9780->97FF - - LD HL,#0x9800 - LD A,#0x10 ; Keep 16 tiles free - LD BC,#12 ; 12 unused columns - LD E,#18 ; 18 lines -2$: - LD D,#20 ; 20 used columns -3$: - LD (HL+),A - INC A - DEC D - JR NZ,3$ - ADD HL,BC - DEC E - JR NZ,2$ - - ;; Turn the screen on - LDH A,(.LCDC) - OR #(LCDCF_ON | LCDCF_BG8000 | LCDCF_BGON) - AND #~LCDCF_BG9C00 ; BG Bank = 0x9800 - LDH (.LCDC),A - - LD A,#.G_MODE - LD (.mode),A - - ;; Setup the default colours and draw modes - LD A,#.M_SOLID - LD (.draw_mode),A - LD A,#0x03 ; Black - LD (.fg_colour),A - LD A,#0x00 ; White - LD (.bg_colour),A - - EI ; Enable interrupts - - RET - - ;; Draw a full-screen image at (BC) -.draw_image:: - LD HL,#0x8000+0x10*0x10 - LD DE,#0x1680 - CALL .copy_vram ; Move the charset - RET - - ;; Replace tile data at (B,C) with data at DE and store old value at HL -.switch_data:: - PUSH DE ; Save src - PUSH HL ; Save dst - LD L,B - SLA L - SLA L - SLA L - LD H,#0x00 - ADD HL,HL - LD D,H - LD E,L - - LD HL,#.y_table - SLA C - SLA C - SLA C - LD B,#0x00 - ADD HL,BC - ADD HL,BC - LD A,(HL+) - LD H,(HL) - LD L,A - ADD HL,DE - - LD B,H ; BC = src - LD C,L - POP HL ; HL = dst - PUSH BC ; Save dst - LD A,H - OR L - JR Z,1$ - LD DE,#0x10 - CALL .copy_vram -1$: - POP HL ; HL = dst - POP BC ; BC = src - LD A,B - OR C - JR Z,2$ - LD DE,#0x10 - CALL .copy_vram -2$: - RET - - .area _CODE - ;; Advance the cursor -.adv_gcurs:: - PUSH HL - LD HL,#.tx ; X coordinate - LD A,#.MAXCURSPOSX - CP (HL) - JR Z,1$ - INC (HL) - JR 99$ -1$: - LD (HL),#0x00 - LD HL,#.ty ; Y coordinate - LD A,#.MAXCURSPOSY - CP (HL) - JR Z,2$ - INC (HL) - JR 99$ -2$: - LD (HL),#0x00 -99$: - POP HL - RET - - ;; Draw a circle from (B,C) with radius D -.circle:: - LD A,B ;Store center values - LD (.x_s),A - LD A,C - LD (.y_s),A - - XOR A - LD (.x_s+1),A - LD A,D - LD (.y_s+1),A - CPL - LD L,A - LD H,#0xFF - INC HL - LD BC,#0 - ADD HL,BC - LD A,L - LD (.l_d+1),A - LD A,H - LD (.l_d),A - -cloop$: - LD A,(.x_s+1) - LD B,A - LD A,(.y_s+1) - SUB B - RET C - - LD A,(.style) - OR A - CALL Z,.circplot - - LD A,(.l_d) - BIT 7,A - JR Z,ycirc$ - - LD A,(.style) - OR A - CALL NZ,.horlin - LD A,(.x_s+1) - INC A - LD (.x_s+1),A - LD A,(.l_d) - LD B,A - LD A,(.l_d+1) - LD C,A - LD H,#0 - LD A,(.x_s+1) - LD L,A - ADD HL,HL - ADD HL,HL - ADD HL,BC - LD BC,#6 - ADD HL,BC - LD A,H - LD (.l_d),A - LD A,L - LD (.l_d+1),A - JR cloop$ -ycirc$: - LD A,(.style) - OR A - CALL NZ,.verlin - LD A,(.x_s+1) - INC A - LD (.x_s+1),A - LD B,#0 - LD A,(.x_s+1) - LD C,A - LD H,#0xFF - LD A,(.y_s+1) - CPL - LD L,A - INC HL - ADD HL,BC - LD A,(.l_d) - LD B,A - LD A,(.l_d+1) - LD C,A - ADD HL,HL - ADD HL,HL - ADD HL,BC - LD BC,#10 - ADD HL,BC - LD A,H - LD (.l_d),A - LD A,L - LD (.l_d+1),A - LD A,(.y_s+1) - DEC A - LD (.y_s+1),A - JP cloop$ - -.horlin:: - LD A,(.x_s) - LD B,A - LD A,(.y_s) - LD C,A - LD A,(.x_s+1) - LD D,A - LD A,(.y_s+1) - LD E,A - PUSH BC - PUSH DE - LD A,B - SUB E - LD H,A - LD A,B - ADD E - LD B,A - LD A,C - ADD D - LD C,A - LD D,H - LD E,C - CALL .line - POP DE - POP BC - LD A,D - OR A - RET Z - PUSH BC - PUSH DE - LD A,B - SUB E - LD H,A - LD A,B - ADD E - LD B,A - LD A,C - SUB D - LD C,A - LD D,H - LD E,C - CALL .line - POP DE - POP BC - RET - -.verlin:: - LD A,(.x_s) - LD B,A - LD A,(.y_s) - LD C,A - LD A,(.x_s+1) - LD D,A - LD A,(.y_s+1) - LD E,A - PUSH BC - PUSH DE - LD A,B - SUB E - LD H,A - LD A,B - ADD E - LD B,A - LD A,C - ADD D - LD C,A - LD D,H - LD E,C - CALL .line - POP DE - POP BC - PUSH BC - PUSH DE - LD A,B - SUB E - LD H,A - LD A,B - ADD E - LD B,A - LD A,C - SUB D - LD C,A - LD D,H - LD E,C - CALL .line - POP DE - POP BC - LD A,D - SUB E - RET Z - PUSH BC - PUSH DE - LD A,B - SUB D - LD H,A - LD A,B - ADD D - LD B,A - LD A,C - SUB E - LD C,A - LD D,H - LD E,C - CALL .line - POP DE - POP BC - PUSH BC - PUSH DE - LD A,B - SUB D - LD H,A - LD A,B - ADD D - LD B,A - LD A,C - ADD E - LD C,A - LD D,H - LD E,C - CALL .line - POP DE - POP BC - RET - -.circplot:: - LD A,(.x_s) - LD B,A - LD A,(.y_s) - LD C,A - LD A,(.x_s+1) - LD D,A - LD A,(.y_s+1) - LD E,A - PUSH BC - PUSH DE - LD A,B - ADD D - LD B,A - LD A,C - SUB E - LD C,A - CALL .plot - POP DE - POP BC - PUSH BC - PUSH DE - LD A,B - SUB E - LD B,A - LD A,C - SUB D - LD C,A - CALL .plot - POP DE - POP BC - PUSH BC - PUSH DE - LD A,B - SUB D - LD B,A - LD A,C - ADD E - LD C,A - CALL .plot - POP DE - POP BC - PUSH BC - PUSH DE - LD A,B - ADD E - LD B,A - LD A,C - ADD D - LD C,A - CALL .plot - POP DE - POP BC - - LD A,D - OR A - RET Z - SUB E - RET Z - - PUSH BC - PUSH DE - LD A,B - SUB D - LD B,A - LD A,C - SUB E - LD C,A - CALL .plot - POP DE - POP BC - PUSH BC - PUSH DE - LD A,B - SUB E - LD B,A - LD A,C - ADD D - LD C,A - CALL .plot - POP DE - POP BC - PUSH BC - PUSH DE - LD A,B - ADD D - LD B,A - LD A,C - ADD E - LD C,A - CALL .plot - POP DE - POP BC - PUSH BC - PUSH DE - LD A,B - ADD E - LD B,A - LD A,C - SUB D - LD C,A - CALL .plot - POP DE - POP BC - RET - - ;; Draw a box between (B,C) and (D,E) -.box:: - LD A,(.x_s) - LD B,A - LD A,(.x_s+1) - LD C,A - SUB B - JR NC,ychk$ - LD A,C - LD (.x_s),A - LD A,B - LD (.x_s+1),A -ychk$: - LD A,(.y_s) - LD B,A - LD A,(.y_s+1) - LD C,A - SUB B - JR NC,dbox$ - LD A,C - LD (.y_s),A - LD A,B - LD (.y_s+1),A -dbox$: - LD A,(.x_s) - LD B,A - LD D,A - LD A,(.y_s) - LD C,A - LD A,(.y_s+1) - LD E,A - CALL .line - LD A,(.x_s+1) - LD B,A - LD D,A - LD A,(.y_s) - LD C,A - LD A,(.y_s+1) - LD E,A - CALL .line - LD A,(.x_s) - INC A - LD (.x_s),A - LD A,(.x_s+1) - DEC A - LD (.x_s+1),A - LD A,(.x_s) - LD B,A - LD A,(.x_s+1) - LD D,A - LD A,(.y_s) - LD C,A - LD E,A - CALL .line - LD A,(.x_s) - LD B,A - LD A,(.x_s+1) - LD D,A - LD A,(.y_s+1) - LD C,A - LD E,A - CALL .line - LD A,(.style) - OR A - RET Z - LD A,(.x_s) - LD B,A - LD A,(.x_s+1) - SUB B - RET C - LD A,(.y_s) - INC A - LD (.y_s),A - LD A,(.y_s+1) - DEC A - LD (.y_s+1),A - LD A,(.y_s) - LD B,A - LD A,(.y_s+1) - SUB B - RET C - - .if 0 - LD A,(.mod_col) ;Swap fore + back colours. - LD D,A - AND #0xF0 - LD C,A ;Preserve Style - LD A,D - AND #0x0C - RRCA - RRCA - OR C ;Foreground->background + style - LD C,A - LD A,D - AND #0x03 - RLCA - RLCA - OR C - LD (.mod_col),A - .else - LD A,(.fg_colour) - LD C,A - LD A,(.bg_colour) - LD (.fg_colour),A - LD A,C - LD (.bg_colour),A - .endif -filllp$: - LD A,(.x_s) - LD B,A - LD A,(.x_s+1) - LD D,A - LD A,(.y_s) - LD C,A - LD E,A - CALL .line - LD A,(.y_s+1) - LD B,A - LD A,(.y_s) - CP B - JR Z,swap$ - INC A - LD (.y_s),A - JR filllp$ -swap$: - .if 0 - LD A,(.mod_col) ;Swap fore + back colours. - LD D,A - AND #0xF0 - LD C,A ;Preserve Style - LD A,D - AND #0x0C - RRCA - RRCA - OR C ;Foreground->background + style - LD C,A - LD A,D - AND #0x03 - RLCA - RLCA - OR C - LD (.mod_col),A - .else - LD A,(.fg_colour) - LD C,A - LD A,(.bg_colour) - LD (.fg_colour),A - LD A,C - LD (.bg_colour),A - .endif - RET - - ;; Draw a line between (B,C) and (D,E) -.line:: - LD A,C ;Calculate Delta Y - SUB E - JR NC,s1$ - CPL - INC A - -s1$: LD (.delta_y),A - LD H,A - - LD A,B ;Calculate Delta X - SUB D - JR NC,s2$ - CPL - INC A - -s2$: LD (.delta_x),A - - SUB H - JP C,y1 - - ;; Use Delta X - - LD A,B - SUB D - JP NC,x2$ - - LD A,C - SUB E - JR Z,x3$ - LD A,#0x00 - JR NC,x3$ - LD A,#0xFF - JR x3$ - -x2$: - LD A,E - SUB C - JR Z,x2a$ - LD A,#0x00 - JR NC,x2a$ - LD A,#0xFF - -x2a$: - LD B,D - LD C,E ;BC holds start X,Y -x3$: - LD (.l_inc),A ;Store Y increment - LD HL,#.y_table - LD D,#0x00 - LD E,C - ADD HL,DE - ADD HL,DE - LD A,(HL+) - LD H,(HL) - LD L,A - - LD A,B - AND #0xf8 - LD E,A - ADD HL,DE - ADD HL,DE - - LD A,(.delta_y) - OR A - JP Z,.xonly - - ;; Got to do it the hard way. - - ; Calculate (2*deltay) -> dinc1 - - PUSH HL - LD H,#0x00 - LD L,A - ADD HL,HL - LD A,H - LD (.dinc1),A - LD A,L - LD (.dinc1+1),A - - ; Calculate (2*deltay)-deltax -> d - - - LD D,H - LD E,L - LD A,(.delta_x) - CPL - LD L,A - LD H,#0xFF - INC HL -dx1$: - ADD HL,DE - LD A,H - LD (.l_d),A - LD A,L - LD (.l_d+1),A - - ; Calculate (deltay-deltax)*2 -> dinc2 - - LD A,(.delta_x) - CPL - LD L,A - LD H,#0xFF - INC HL - LD A,(.delta_y) - LD D,#0x00 - LD E,A - ADD HL,DE - ADD HL,HL - - LD A,H - LD (.dinc2),A - LD A,L - LD (.dinc2+1),A - - POP HL - - .if 0 - LD A,(.mod_col) - LD D,A - .endif - - LD A,(.delta_x) - LD E,A - - LD A,B - AND #7 - ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 - LD C,A - LD B,#0x00 - LD A,(BC) ; Get start bit - LD B,A - LD C,A - -xloop$: - RRC C - LD A,(.l_d) - BIT 7,A - JR Z,ychg$ - PUSH DE - BIT 7,C - JR Z,nbit$ - LD A,B - CPL - LD C,A - CALL .wrbyte - DEC HL - LD C,#0x80 - LD B,C -nbit$: - LD A,(.l_d+1) - LD D,A - LD A,(.dinc1+1) - ADD D - LD (.l_d+1),A - LD A,(.l_d) - LD D,A - LD A,(.dinc1) - ADC D - LD (.l_d),A - POP DE - JR nchg$ -ychg$: - PUSH DE - PUSH BC - LD A,B - CPL - LD C,A - CALL .wrbyte - LD A,(.l_inc) - OR A - JR Z,ydown$ - INC HL - LD A,L - AND #0x0F - JR NZ,bound$ - LD DE,#0x0130 - ADD HL,DE ;Correct screen address - JR bound$ -ydown$: - DEC HL - DEC HL - DEC HL - LD A,L - AND #0x0F - XOR #0x0E - JR NZ,bound$ - LD DE,#0xFED0 - ADD HL,DE ;Correct screen address -bound$: - LD A,(.l_d+1) - LD D,A - LD A,(.dinc2+1) - ADD D - LD (.l_d+1),A - LD A,(.l_d) - LD D,A - LD A,(.dinc2) - ADC D - LD (.l_d),A - POP BC - LD B,C - POP DE -nchg$: - BIT 7,C - JR Z,nadj$ - PUSH DE - LD DE,#0x0010 - ADD HL,DE ;Correct screen address - POP DE - LD B,C -nadj$: - LD A,B - OR C - LD B,A - DEC E - JP NZ,xloop$ - LD A,B - CPL - LD C,A - JP .wrbyte - -.xonly:: - ;; Draw accelerated horizontal line - .if 0 - ;; xxx needed? - LD A,(.mod_col) - LD D,A - .endif - - LD A,(.delta_x) - LD E,A - INC E - - LD A,B ;check X - AND #7 ;just look at bottom 3 bits - JR Z,2$ - PUSH HL - ADD #<.drawing_bits_tbl ;Table of bits is located at 0x0070 - LD L,A - LD H,#0x00 - LD C,(HL) - POP HL - XOR A ;Clear A -1$: RRCA ;Shift data right 1 - OR C - DEC E - JR Z,3$ - BIT 0,A - JR Z,1$ - JR 3$ -2$: - LD A,E - DEC A - AND #0xF8 - JR Z,4$ - JR 8$ -3$: - LD B,A - CPL - LD C,A - PUSH DE - CALL .wrbyte - LD DE,#0x0F - ADD HL,DE ;Correct screen address - POP DE - -8$: LD A,E - OR A - RET Z - AND #0xF8 - JR Z,4$ - - XOR A - LD C,A - CPL - LD B,A - - PUSH DE - CALL .wrbyte - LD DE,#0x0F - ADD HL,DE ;Correct screen address - POP DE - LD A,E - SUB #8 - RET Z - LD E,A - JR 8$ - -4$: LD A,#0x80 -5$: DEC E - JR Z,6$ - SRA A - JR 5$ -6$: LD B,A - CPL - LD C,A - JP .wrbyte - - ;; Use Delta Y -y1: - LD A,C - SUB E - JP NC,y2$ - - LD A,B - SUB D - JR Z,y3$ - LD A,#0x00 - JR NC,y3$ - LD A,#0xFF - JR y3$ - -y2$: - LD A,C - SUB E - JR Z,y2a$ - LD A,#0x00 - -; JR NC,y2a$ ; old code; fix draw to up-left below -; LD A,#0xFF - - LD L,A ; invert delta if x1 less than x2 - LD A,B - SUB D - LD A,L - JR C,y2a$ - CPL - -y2a$: - LD B,D - LD C,E ;BC holds start X,Y - -y3$: - LD (.l_inc),A ;Store X increment - LD HL,#.y_table - LD D,#0x00 - LD E,C - ADD HL,DE - ADD HL,DE - LD A,(HL+) - LD H,(HL) - LD L,A - - LD A,B - AND #0xf8 - LD E,A - ADD HL,DE - ADD HL,DE - - .if 0 - ;; Trashed by later instructions - LD A,(.mod_col) - LD D,A - .endif - - LD A,(.delta_y) - LD E,A - INC E - - LD A,(.delta_x) - OR A - JP Z,.yonly - - ;; Got to do it the hard way. - - ; Calculate (2*deltax) -> dinc1 - - PUSH HL - LD H,#0x00 - LD L,A - ADD HL,HL - LD A,H - LD (.dinc1),A - LD A,L - LD (.dinc1+1),A - - ; Calculate (2*deltax)-deltay -> d - - - LD D,H - LD E,L - LD A,(.delta_y) - CPL - LD L,A - LD H,#0xFF - INC HL -dy1$: - ADD HL,DE - LD A,H - LD (.l_d),A - LD A,L - LD (.l_d+1),A - - ; Calculate (deltax-deltay)*2 -> dinc2 - - LD A,(.delta_y) - CPL - LD L,A - LD H,#0xFF - INC HL - LD A,(.delta_x) - LD D,#0x00 - LD E,A - ADD HL,DE - ADD HL,HL - - LD A,H - LD (.dinc2),A - LD A,L - LD (.dinc2+1),A - - POP HL - - .if 0 - ;; xxx Not used? - LD A,(.mod_col) - LD D,A - .endif - - LD A,(.delta_y) - LD E,A - - LD A,B - AND #7 - ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 - LD C,A - LD B,#0x00 - LD A,(BC) ; Get start bit - LD B,A - LD C,A - -yloop$: - PUSH DE - PUSH BC - LD A,B - CPL - LD C,A - CALL .wrbyte - INC HL - LD A,L - AND #0x0F - JR NZ,nybound$ - LD DE,#0x0130 - ADD HL,DE ;Correct screen address -nybound$: - POP BC - LD A,(.l_d) - BIT 7,A - JR Z,xchg$ - LD A,(.l_d+1) - LD D,A - LD A,(.dinc1+1) - ADD D - LD (.l_d+1),A - LD A,(.l_d) - LD D,A - LD A,(.dinc1) - ADC D - LD (.l_d),A - JR nchgy$ -xchg$: - LD A,(.l_inc) - OR A - JR NZ,yright$ - RLC B - BIT 0,B - JR Z,boundy$ - LD DE,#0xFFF0 - ADD HL,DE ;Correct screen address - JR boundy$ -yright$: - RRC B - BIT 7,B - JR Z,boundy$ - LD DE,#0x0010 - ADD HL,DE ;Correct screen address -boundy$: - LD A,(.l_d+1) - LD D,A - LD A,(.dinc2+1) - ADD D - LD (.l_d+1),A - LD A,(.l_d) - LD D,A - LD A,(.dinc2) - ADC D - LD (.l_d),A -nchgy$: - POP DE - DEC E - JR NZ,yloop$ - LD A,B - CPL - LD C,A - JP .wrbyte - -.yonly:: - ;; Draw accelerated vertical line - LD A,B ;check X - AND #7 ;just look at bottom 3 bits - PUSH HL - ADD #<.drawing_bits_tbl ;Table of bits is located at 0x0070 - LD L,A - LD H,#0x00 - LD A,(HL) ;Get mask bit - POP HL - LD B,A - CPL - LD C,A - -1$: PUSH DE - CALL .wrbyte - INC HL ;Correct screen address - LD A,L - AND #0x0F - JR NZ,2$ - LD DE,#0x0130 - ADD HL,DE -2$: POP DE - DEC E - RET Z - JR 1$ - - ;; Draw a point at (B,C) with mode and color D -.plot:: - - LD HL,#.y_table - LD D,#0x00 - LD E,C - ADD HL,DE - ADD HL,DE - LD A,(HL+) - LD H,(HL) - LD L,A - - LD A,B - AND #0xf8 - LD E,A - ADD HL,DE - ADD HL,DE - - LD A,B - - AND #7 - ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 - LD C,A - LD B,#0x00 - LD A,(BC) - LD B,A - CPL - LD C,A - -.wrbyte:: - .if 0 - LD A,(.mod_col) ; Restore color and mode - LD D,A - - BIT 5,D - JR NZ,10$ - BIT 6,D - JR NZ,20$ - BIT 7,D - JR NZ,30$ - .else - LD A,(.fg_colour) - LD D,A - LD A,(.draw_mode) - CP #.M_OR - JR Z,10$ - CP #.M_XOR - JR Z,20$ - CP #.M_AND - JR Z,30$ - .endif - - ; Fall through to SOLID by default -1$: - ;; Solid - LD E,B - .if 0 - BIT 2,D - .else - BIT 0,D - .endif - JR NZ,2$ - PUSH BC - LD B,#0x00 -2$: - .if 0 - BIT 3,D - .else - BIT 1,D - .endif - JR NZ,3$ - LD E,#0x00 -3$: - WAIT_STAT - - LD A,(HL) - AND C - OR B - LD (HL+),A - - LD A,(HL) - AND C - OR E - LD (HL),A - LD A,B - OR A - RET NZ - POP BC - RET - -10$: - ;; Or - LD C,B - .if 0 - BIT 2,D - .else - BIT 0,D - .endif - JR NZ,11$ - LD B,#0x00 -11$: - .if 0 - BIT 3,D - .else - BIT 1,D - .endif - JR NZ,12$ - LD C,#0x00 -12$: - WAIT_STAT - - LD A,(HL) - OR B - LD (HL+),A - - LD A,(HL) - OR C - LD (HL),A - RET - -20$: - ;; Xor - LD C,B - .if 0 - BIT 2,D - .else - BIT 0,D - .endif - JR NZ,21$ - LD B,#0x00 -21$: - .if 0 - BIT 3,D - .else - BIT 1,D - .endif - JR NZ,22$ - LD C,#0x00 -22$: - WAIT_STAT - - LD A,(HL) - XOR B - LD (HL+),A - - LD A,(HL) - XOR C - LD (HL),A - RET - -30$: - ;; And - LD B,C - .if 0 - BIT 2,D - .else - BIT 0,D - .endif - JR Z,31$ - LD B,#0xFF -31$: - .if 0 - BIT 3,D - .else - BIT 1,D - .endif - JR Z,32$ - LD C,#0xFF -32$: - WAIT_STAT - - LD A,(HL) - AND B - LD (HL+),A - - LD A,(HL) - AND C - LD (HL),A - RET - - ;; Get color of pixel at point (B,C) returns in A -.getpix:: - LD HL,#.y_table - LD D,#0x00 - LD E,C - ADD HL,DE - ADD HL,DE - LD A,(HL+) - LD H,(HL) - LD L,A - - LD A,B - AND #0xf8 - LD E,A - ADD HL,DE - ADD HL,DE - - LD A,B - - AND #7 - ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 - LD C,A - LD B,#0x00 - LD A,(BC) - LD C,A - - WAIT_STAT - - LD A,(HL+) - LD D,A - LD A,(HL+) - LD E,A - LD B,#0 - LD A,D - AND C - JR Z,1$ - SET 0,B -1$: LD A,E - AND C - JR Z,2$ - SET 1,B -2$: LD E,B - RET - - ;; Write character C -.wrtchr:: - LD HL,#.y_table - LD D,#0x00 - LD A,(.ty) - RLCA - RLCA - RLCA - LD E,A - ADD HL,DE - ADD HL,DE - LD A,(HL+) - LD B, A - LD H,(HL) - LD L,B - - LD A,(.tx) - RLCA - RLCA - RLCA - LD E,A - ADD HL,DE - ADD HL,DE - - LD A,C - LD B,H - LD C,L - - LD H,D - LD L,A - ADD HL,HL - ADD HL,HL - ADD HL,HL - - .if 0 - LD DE,#.tp1 - .else - .globl _font_ibm_fixed_tiles - - LD DE,#_font_ibm_fixed_tiles - .endif - - ADD HL,DE - - LD D,H - LD E,L - LD H,B - LD L,C - - .if 0 - LD A,(.mod_col) - LD C,A - .else - LD A,(.fg_colour) - LD C,A - .endif -1$: - LD A,(DE) - INC DE - PUSH DE - - .if 1 - PUSH HL - LD HL,#.bg_colour - LD L,(HL) - .endif - - LD B,A - XOR A - .if 0 - BIT 0,C - .else - BIT 0,L - .endif - JR Z,2$ - CPL -2$: OR B - .if 0 - BIT 2,C - .else - BIT 0,C - .endif - JR NZ,3$ - XOR B -3$: LD D,A - XOR A - .if 0 - BIT 1,C - .else - BIT 1,L - .endif - JR Z,4$ - CPL -4$: OR B - .if 0 - BIT 3,C - .else - BIT 1,C - .endif - JR NZ,5$ - XOR B -5$: - LD E,A - .if 1 - POP HL - .endif - - WAIT_STAT - - LD A,D - LD (HL+),A - LD A,E - LD (HL+),A - POP DE - LD A,L - AND #0x0F - JR NZ,1$ - RET - - .area _CODE -_gotogxy:: ; Banked - LDA HL,.BANKOV(SP) ; Skip return address - LD A,(HL+) ; A = x - LD (.tx),A - LD A,(HL+) ; A = y - LD (.ty),A - - RET - -_wrtchr:: ; Banked - PUSH BC - - LD A,(.mode) - CP #.G_MODE - CALL NZ,.gmode - - LDA HL,.BANKOV+2(SP) ; Skip return address and registers - LD A,(HL) - LD C,A ; C = Char to print - - CALL .wrtchr - CALL .adv_gcurs - - POP BC - RET - -_getpix:: ; Banked - PUSH BC - - LDA HL,.BANKOV+2(SP) ; Skip return address and registers - LD A,(HL+) ; B = x - LD B,A - LD A,(HL+) ; C = y - LD C,A - - CALL .getpix - - POP BC - RET - -_circle:: ; Banked - PUSH BC - - LD A,(.mode) - CP #.G_MODE - CALL NZ,.gmode - - LDA HL,.BANKOV+2(SP) ; Skip return address and registers - LD A,(HL+) ; B = x - LD B,A - LD A,(HL+) ; C = y - LD C,A - LD A,(HL+) ; D = Radius - LD D,A - LD A,(HL) - LD (.style),A - - CALL .circle - - POP BC - RET - -_box:: ; Banked - PUSH BC - - LD A,(.mode) - CP #.G_MODE - CALL NZ,.gmode - - LDA HL,.BANKOV+2(SP) ; Skip return address and registers - LD A,(HL+) ; B = x1 - LD (.x_s),A - LD A,(HL+) ; C = y1 - LD (.y_s),A - LD A,(HL+) ; D = x2 - LD (.x_s+1),A - LD A,(HL+) ; E = y2 - LD (.y_s+1),A - LD A,(HL) - LD (.style),A - CALL .box - POP BC - RET - -_line:: ; Banked - PUSH BC - - LD A,(.mode) - CP #.G_MODE - CALL NZ,.gmode - - LDA HL,.BANKOV+2(SP) ; Skip return address and registers - LD A,(HL+) ; B = x1 - LD B,A - LD A,(HL+) ; C = y1 - LD C,A - LD A,(HL+) ; D = x2 - LD D,A - LD A,(HL+) ; E = y2 - LD E,A - - CALL .line - - POP BC - RET - -_plot_point:: ; Banked - PUSH BC - - LD A,(.mode) - CP #.G_MODE - CALL NZ,.gmode - - LDA HL,.BANKOV+2(SP) ; Skip return address and registers - LD A,(HL+) ; B = x - LD B,A - LD A,(HL+) ; C = y - LD C,A - - CALL .plot - - POP BC - RET - - ;; Old, compatible version of plot() -_plot:: ; Banked - PUSH BC - - LD A,(.mode) - CP #.G_MODE - CALL NZ,.gmode - - LDA HL,.BANKOV+2(SP) ; Skip return address and registers - LD A,(HL+) ; B = x - LD B,A - LD A,(HL+) ; C = y - LD C,A - LD A,(HL+) ; colour - LD (.fg_colour),A - LD A,(HL+) ; mode - LD (.draw_mode),A - - CALL .plot - - POP BC - RET - - .area _BASE -_switch_data:: ; Non Banked as pointer - PUSH BC - - LD A,(.mode) - CP #.G_MODE - CALL NZ,.gmode - - LDA HL,4(SP) ; Skip return address and registers - LD A,(HL+) ; B = x - LD B,A - LD A,(HL+) ; C = y - LD C,A - LD A,(HL+) ; DE = src - LD E,A - LD A,(HL+) - LD D,A - LD A,(HL+) ; HL = dst - LD H,(HL) - LD L,A - - CALL .switch_data - - POP BC - RET - - -_draw_image:: ; Non banked as pointer - PUSH BC - - LD A,(.mode) - CP #.G_MODE - CALL NZ,.gmode - - LDA HL,4(SP) ; Skip return address and registers - LD A,(HL+) ; HL = data - LD C,A - LD B,(HL) - - CALL .draw_image - - POP BC - RET - - .area _BASE -.y_table:: - .word 0x8100,0x8102,0x8104,0x8106,0x8108,0x810A,0x810C,0x810E - .word 0x8240,0x8242,0x8244,0x8246,0x8248,0x824A,0x824C,0x824E - .word 0x8380,0x8382,0x8384,0x8386,0x8388,0x838A,0x838C,0x838E - .word 0x84C0,0x84C2,0x84C4,0x84C6,0x84C8,0x84CA,0x84CC,0x84CE - .word 0x8600,0x8602,0x8604,0x8606,0x8608,0x860A,0x860C,0x860E - .word 0x8740,0x8742,0x8744,0x8746,0x8748,0x874A,0x874C,0x874E - .word 0x8880,0x8882,0x8884,0x8886,0x8888,0x888A,0x888C,0x888E - .word 0x89C0,0x89C2,0x89C4,0x89C6,0x89C8,0x89CA,0x89CC,0x89CE - .word 0x8B00,0x8B02,0x8B04,0x8B06,0x8B08,0x8B0A,0x8B0C,0x8B0E - .word 0x8C40,0x8C42,0x8C44,0x8C46,0x8C48,0x8C4A,0x8C4C,0x8C4E - .word 0x8D80,0x8D82,0x8D84,0x8D86,0x8D88,0x8D8A,0x8D8C,0x8D8E - .word 0x8EC0,0x8EC2,0x8EC4,0x8EC6,0x8EC8,0x8ECA,0x8ECC,0x8ECE - .word 0x9000,0x9002,0x9004,0x9006,0x9008,0x900A,0x900C,0x900E - .word 0x9140,0x9142,0x9144,0x9146,0x9148,0x914A,0x914C,0x914E - .word 0x9280,0x9282,0x9284,0x9286,0x9288,0x928A,0x928C,0x928E - .word 0x93C0,0x93C2,0x93C4,0x93C6,0x93C8,0x93CA,0x93CC,0x93CE - .word 0x9500,0x9502,0x9504,0x9506,0x9508,0x950A,0x950C,0x950E - .word 0x9640,0x9642,0x9644,0x9646,0x9648,0x964A,0x964C,0x964E diff --git a/gbdk-lib/libc/gb/drawing_isr.s b/gbdk-lib/libc/gb/drawing_isr.s @@ -1,23 +0,0 @@ - .include "global.s" - - .area _BASE - -.drawing_vbl:: - LDH A,(.LCDC) - OR #LCDCF_BG8000 ; Set BG Chr to 0x8000 - LDH (.LCDC),A - - LD A,#72 ; Set line at which LCD interrupt occurs - LDH (.LYC),A - - RET - - ;; Is the STAT check required, as we are already in the HBL? -.drawing_lcd:: - WAIT_STAT - - LDH A,(.LCDC) - AND #~LCDCF_BG8000 ; Set BG Chr to 0x8800 - LDH (.LCDC),A - - RET diff --git a/gbdk-lib/libc/gb/font.s b/gbdk-lib/libc/gb/font.s @@ -1,705 +0,0 @@ -; font.ms -; -; Michael Hope, 1999 -; michaelh@earthling.net -; Distrubuted under the Artistic License - see www.opensource.org -; - .include "global.s" - - .globl .cr_curs - .globl .adv_curs - .globl .cury, .curx - .globl .display_off - - ; Structure offsets - sfont_handle_sizeof = 3 - sfont_handle_font = 1 - sfont_handle_first_tile = 0 - - ; Encoding types - lower 2 bits of font - FONT_256ENCODING = 0 - FONT_128ENCODING = 1 - FONT_NOENCODING = 2 - - ; Other bits - FONT_BCOMPRESSED = 2 - - .CR = 0x0A ; Unix - .SPACE = 0x00 - - ; Maximum number of fonts - .MAX_FONTS = 6 - - .area _FONT_HEADER (ABS) - - .org .MODE_TABLE+4*.T_MODE - JP .tmode - - .module font.ms - - ; Globals from drawing.s - ; FIXME: Hmmm... check the linkage of these - .globl .fg_colour - .globl .bg_colour - - .area _BSS - ; The current font -.start_font_vars: - -font_current:: - .ds sfont_handle_sizeof - ; Cached copy of the first free tile -font_first_free_tile:: - .ds 1 - ; Table containing descriptors for all of the fonts -font_table:: - .ds sfont_handle_sizeof*.MAX_FONTS -.end_font_vars: - - .area _GSINIT - - xor a - ld (#.curx),a - ld (#.cury),a - ld hl,#.start_font_vars - ld c,#(.end_font_vars - .start_font_vars) - rst 0x28 - - .area _BASE - -_font_load_ibm:: ; Banked - ld hl,#_font_ibm - call font_load - ret - - ; Copy uncompressed 16 byte tiles from (BC) to (HL), length = DE*2 - ; Note: HL must be aligned on a uint16_t boundry -font_copy_uncompressed:: - ld a,d - or e - ret z - - ld a,h - cp #0x98 - jr c,4$ - sub #0x98-0x88 - ld h,a -4$: - xor a - cp e ; Special for when e=0 you will get another loop - jr nz,1$ - dec d -1$: - WAIT_STAT - ld a,(bc) - ld (hl+),a - inc bc - - WAIT_STAT - ld a,(bc) - ld (hl),a - inc bc - - inc l - jr nz,2$ - inc h - ld a,h ; Special wrap-around - cp #0x98 - jr nz,2$ - ld h,#0x88 -2$: - dec e - jr nz,1$ - dec d - bit 7,d ; -1? - jr z,1$ - ret - - ; Copy a set of compressed (8 bytes/cell) tiles to VRAM - ; Sets the foreground and background colours based on the current - ; font colours - ; Entry: - ; From (BC) to (HL), length (DE) where DE = #cells * 8 - ; Uses the current fg_colour and bg_colour fields -font_copy_compressed:: - ld a,d - or e - ret z ; Do nothing - - ld a,h - cp #0x98 ; Take care of the 97FF -> 8800 wrap around - jr c,font_copy_compressed_loop - sub #0x98-0x88 - ld h,a -font_copy_compressed_loop: - push de - ld a,(bc) - ld e,a - inc bc - push bc - - ld bc,#0 - ; Do the background colour first - ld a,(.bg_colour) - bit 0,a - jr z,font_copy_compressed_bg_grey1 - ld b,#0xFF -font_copy_compressed_bg_grey1: - bit 1,a - jr z,font_copy_compressed_bg_grey2 - ld c,#0xFF -font_copy_compressed_bg_grey2: - ; BC contains the background colour - ; Compute what xoring we need to do to get the correct fg colour - ld d,a - ld a,(.fg_colour) - xor d - ld d,a - - bit 0,d - jr z,font_copy_compressed_grey1 - ld a,e - xor b - ld b,a -font_copy_compressed_grey1: - bit 1,d - jr z,font_copy_compressed_grey2 - ld a,e - xor c - ld c,a -font_copy_compressed_grey2: - WAIT_STAT - - ld (hl),b - inc l ; can't overflow here - ld (hl),c - inc hl - - ld a,h ; Take care of the 97FFF -> 8800 wrap around - cp #0x98 - jr nz,1$ - ld h,#0x88 -1$: - pop bc - pop de - dec de - ld a,d - or e - jr nz,font_copy_compressed_loop - ret - -; Load the font HL -font_load:: - call .display_off - push hl - - ; Find the first free font entry - ld hl,#font_table+sfont_handle_font - ld b,#.MAX_FONTS -font_load_find_slot: - ld a,(hl) ; Check to see if this entry is free - inc hl ; Free is 0000 for the font pointer - or (hl) - cp #0 - jr z,font_load_found - - inc hl - inc hl - dec b - jr nz,font_load_find_slot - pop hl - ld hl,#0 - jr font_load_exit ; Couldn't find a free space -font_load_found: - ; HL points to the end of the free font table entry - pop de - ld (hl),d ; Copy across the font struct pointer - dec hl - ld (hl),e - - ld a,(font_first_free_tile) - dec hl - ld (hl),a - - push hl - call font_set ; Set this new font to be the default - - ; Only copy the tiles in if were in text mode - ld a,(.mode) - and #.T_MODE - - call nz,font_copy_current - - ; Increase the 'first free tile' counter - ld hl,#font_current+sfont_handle_font - ld a,(hl+) - ld h,(hl) - ld l,a - - inc hl ; Number of tiles used - ld a,(font_first_free_tile) - add a,(hl) - ld (font_first_free_tile),a - - pop hl ; Return font setup in HL -font_load_exit: - ;; Turn the screen on - LDH A,(.LCDC) - OR #(LCDCF_ON | LCDCF_BGON) - AND #~(LCDCF_BG9C00 | LCDCF_BG8000) - LDH (.LCDC),A - - RET - - ; Copy the tiles from the current font into VRAM -font_copy_current:: - ; Find the current font data - ld hl,#font_current+sfont_handle_font - ld a,(hl+) - ld h,(hl) - ld l,a - - inc hl ; Points to the 'tiles required' entry - ld a,(hl-) - ld d,#0 - rla ; Multiple DE by 8 - rl d - rla - rl d - rla - rl d - ld e, a ; DE has the length of the tile data - - ld a,(hl) ; Get the flags - push af - and #3 ; Only lower 2 bits set encoding table size - - ld bc,#128 - cp #FONT_128ENCODING ; 0 for 256 char encoding table, 1 for 128 char - jr z,font_copy_current_copy - - ld bc,#0 - cp #FONT_NOENCODING - jr z,font_copy_current_copy - - ld bc,#256 ; Must be 256 element encoding -font_copy_current_copy: - inc hl - inc hl ; Points to the start of the encoding table - add hl,bc - ld c,l - ld b,h ; BC points to the start of the tile data - - ; Find the offset in VRAM for this font - ld a,(font_current+sfont_handle_first_tile) ; First tile used for this font - swap a - ld l,a - and #0x0f - ld h,a - ld a, l - and #0xf0 - ld l, a - - ld a,#0x90 ; Tile 0 is at 9000h - add a,h - ld h,a - ; Is this font compressed? - pop af ; Recover flags - bit FONT_BCOMPRESSED,a - ; Do the jump in a mildly different way - jp z,font_copy_uncompressed - jp font_copy_compressed - - ; Set the current font to HL -font_set:: - ld a,(hl+) - ld (font_current),a - ld a,(hl+) - ld (font_current+1),a - ld a,(hl+) - ld (font_current+2),a - ret - - ;; Print a character with interpretation -.put_char:: - ; See if it's a special char - cp #.CR - jr nz,1$ - - ; Now see if were checking special chars - push af - ld a,(.mode) - and #.M_NO_INTERP - jr nz,2$ - call .cr_curs - pop af - ret -2$: - pop af -1$: - call .set_char - jp .adv_curs - - ;; Print a character without interpretation -.out_char:: - call .set_char - jp .adv_curs - - ;; Delete a character -.del_char:: - call .rew_curs - ld a,#.SPACE - jp .set_char - - ;; Print the character in A -.set_char: - push af - ld a,(font_current+2) - ; Must be non-zero if the font system is setup (cant have a font in page zero) - or a - jr nz,3$ - - ; Font system is not yet setup - init it and copy in the ibm font - ; Kind of a compatibility mode - call _font_init - - ; Need all of the tiles - xor a - ld (font_first_free_tile),a - - call _font_load_ibm -3$: - pop af - push bc - push de - push hl - ; Compute which tile maps to this character - ld e,a - ld hl,#font_current+sfont_handle_font - ld a,(hl+) - ld h,(hl) - ld l,a - ld a,(hl+) - and #3 - cp #FONT_NOENCODING - jr z,set_char_no_encoding - inc hl - ; Now at the base of the encoding table - ; E is set above - ld d,#0 - add hl,de - ld e,(hl) ; That's the tile! -set_char_no_encoding: - ld a,(font_current+0) - add a,e - ld e,a - - LD A,(.cury) ; Y coordinate - LD L,A - LD H,#0x00 - ADD HL,HL - ADD HL,HL - ADD HL,HL - ADD HL,HL - ADD HL,HL - LD A,(.curx) ; X coordinate - LD C,A - LD B,#0x00 - ADD HL,BC - LD BC,#0x9800 - ADD HL,BC - - WAIT_STAT - - LD (HL),E - POP HL - POP DE - POP BC - RET - - .area _CODE -_putchar:: ; Banked - PUSH BC - LDA HL,.BANKOV+2(SP); Skip return address - LD A,(HL) ; A = c - CALL .put_char - POP BC - RET - -_setchar:: ; Banked - PUSH BC - LDA HL,.BANKOV+2(SP); Skip return address - LD A,(HL) ; A = c - CALL .set_char - POP BC - RET - - .area _BASE -_font_load:: - push bc - LDA HL,4(SP) ; Skip return address and bc - LD A,(HL) ; A = c - inc hl - ld h,(hl) - ld l,a - call font_load - push hl - pop de ; Return in DE - pop bc - ret - -_font_set:: - push bc - LDA HL,4(SP) ; Skip return address - LD A,(HL) ; A = c - inc hl - ld h,(hl) - ld l,a - call font_set - pop bc - ld de,#0 ; Always good... - ret - -_font_init:: - push bc - .globl .tmode - - call .tmode - - xor a - ld (font_first_free_tile),a - - ; Clear the font table - ld hl,#font_table - ld b,#sfont_handle_sizeof*.MAX_FONTS -1$: - ld (hl+),a - dec b - jr nz,1$ - ld a,#3 - ld (.fg_colour),a - ld a,#0 - ld (.bg_colour),a - - call .cls - pop bc - ret - -_cls:: -.cls:: - PUSH DE - PUSH HL - LD HL,#0x9800 - LD E,#0x20 ; E = height -1$: - LD D,#0x20 ; D = width -2$: - WAIT_STAT - - LD (HL),#.SPACE ; Always clear - INC HL - DEC D - JR NZ,2$ - DEC E - JR NZ,1$ - POP HL - POP DE - RET - - .area _CODE - ; Support routines -_gotoxy:: ; Banked - lda hl,.BANKOV(sp) - ld a,(hl+) - ld (.curx),a - ld a,(hl) - ld (.cury),a - ret - -_posx:: - LD A,(.mode) ; Banked - AND #.T_MODE - JR NZ,1$ - PUSH BC - CALL .tmode - POP BC -1$: - LD A,(.curx) - LD E,A - RET - -_posy:: ; Banked - LD A,(.mode) - AND #.T_MODE - JR NZ,1$ - PUSH BC - CALL .tmode - POP BC -1$: - LD A,(.cury) - LD E,A - RET - - .area _BASE - ;; Rewind the cursor -.rew_curs: - PUSH HL - LD HL,#.curx ; X coordinate - XOR A - CP (HL) - JR Z,1$ - DEC (HL) - JR 99$ -1$: - LD (HL),#.MAXCURSPOSX - LD HL,#.cury ; Y coordinate - XOR A - CP (HL) - JR Z,99$ - DEC (HL) -99$: - POP HL - RET - -.cr_curs:: - PUSH HL - XOR A - LD (.curx),A - LD HL,#.cury ; Y coordinate - LD A,#.MAXCURSPOSY - CP (HL) - JR Z,2$ - INC (HL) - JR 99$ -2$: - CALL .scroll -99$: - POP HL - RET - -.adv_curs:: - PUSH HL - LD HL,#.curx ; X coordinate - LD A,#.MAXCURSPOSX - CP (HL) - JR Z,1$ - INC (HL) - JR 99$ -1$: - LD (HL),#0x00 - LD HL,#.cury ; Y coordinate - LD A,#.MAXCURSPOSY - CP (HL) - JR Z,2$ - INC (HL) - JR 99$ -2$: - ;; See if scrolling is disabled - LD A,(.mode) - AND #.M_NO_SCROLL - JR Z,3$ - ;; Nope - reset the cursor to (0,0) - XOR A - LD (.cury),A - LD (.curx),A - JR 99$ -3$: - CALL .scroll -99$: - POP HL - RET - - ;; Scroll the whole screen -.scroll: - PUSH BC - PUSH DE - PUSH HL - LD HL,#0x9800 - LD BC,#0x9800+0x20 ; BC = next line - LD E,#0x20-0x01 ; E = height - 1 -1$: - LD D,#0x20 ; D = width -2$: - WAIT_STAT - LD A,(BC) - LD (HL+),A - INC BC - - DEC D - JR NZ,2$ - DEC E - JR NZ,1$ - - LD D,#0x20 -3$: - WAIT_STAT - LD A,#.SPACE - LD (HL+),A - DEC D - JR NZ,3$ - - POP HL - POP DE - POP BC - RET - - .area _BSS -.curx:: ; Cursor position - .ds 0x01 -.cury:: - .ds 0x01 - - .area _BASE - - .globl .drawing_vbl - .globl .drawing_lcd - .globl .int_0x40 - .globl .int_0x48 - .globl .remove_int - - ;; Enter text mode -.tmode:: - DI ; Disable interrupts - - ;; Turn the screen off - LDH A,(.LCDC) - AND #LCDCF_ON - JR Z,1$ - - ;; Turn the screen off - CALL .display_off - - ;; Remove any interrupts setup by the drawing routine - LD BC,#.drawing_vbl - LD HL,#.int_0x40 - CALL .remove_int - LD BC,#.drawing_lcd - LD HL,#.int_0x48 - CALL .remove_int -1$: - - CALL .tmode_out - - ;; Turn the screen on - LDH A,(.LCDC) - OR #(LCDCF_ON | LCDCF_BGON) - AND #~(LCDCF_BG9C00 | LCDCF_BG8000) - LDH (.LCDC),A - - EI ; Enable interrupts - - RET - - ;; Text mode (out only) -.tmode_out:: - XOR A - LD (.curx),A - LD (.cury),A - - ;; Clear screen - CALL .cls - - LD A,#.T_MODE - LD (.mode),A - - RET diff --git a/gbdk-lib/libc/gb/global.s b/gbdk-lib/libc/gb/global.s @@ -1,502 +0,0 @@ - .NEAR_CALLS = 1 ; <near_calls> - tag so that sed can change this - - ;; Changed by astorgb.pl to 1 - __RGBDS__ = 0 - - _VRAM = 0x8000 ; $8000->$9FFF - _VRAM8000 = _VRAM - _VRAM8800 = _VRAM+0x800 - _VRAM9000 = _VRAM+0x1000 - _SCRN0 = 0x9800 ; $9800->$9BFF - _SCRN1 = 0x9C00 ; $9C00->$9FFF - _SRAM = 0xA000 ; $A000->$BFFF - _RAM = 0xC000 ; $C000->$CFFF / $C000->$DFFF - _RAMBANK = 0xD000 ; $D000->$DFFF - _OAMRAM = 0xFE00 ; $FE00->$FE9F - _IO = 0xFF00 ; $FF00->$FF7F,$FFFF - _AUD3WAVERAM = 0xFF30 ; $FF30->$FF3F - _HRAM = 0xFF80 ; $FF80->$FFFE - - ;; MBC Equates - - .MBC1_ROM_PAGE = 0x2000 ; Address to write to for MBC1 switching - - rRAMG = 0x0000 ; $0000->$1fff - rROMB0 = 0x2000 ; $2000->$2fff - rROMB1 = 0x3000 ; $3000->$3fff - If more than 256 ROM banks are present. - rRAMB = 0x4000 ; $4000->$5fff - Bit 3 enables rumble (if present) - - ;; Keypad - .START = 0x80 - .SELECT = 0x40 - .B = 0x20 - .A = 0x10 - .DOWN = 0x08 - .UP = 0x04 - .LEFT = 0x02 - .RIGHT = 0x01 - - .P14 = 0x10 - .P15 = 0x20 - - ;; Screen dimensions - .MAXCURSPOSX = 0x13 ; In tiles - .MAXCURSPOSY = 0x11 - - .SCREENWIDTH = 0xA0 - .SCREENHEIGHT = 0x90 - .MINWNDPOSX = 0x07 - .MINWNDPOSY = 0x00 - .MAXWNDPOSX = 0xA6 - .MAXWNDPOSY = 0x8F - - ;; Hardware registers - - .P1 = 0x00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10 - rP1 = 0xFF00 - - P1F_5 = 0b00100000 ; P15 out port, set to 0 to get buttons - P1F_4 = 0b00010000 ; P14 out port, set to 0 to get dpad - P1F_3 = 0b00001000 ; P13 in port - P1F_2 = 0b00000100 ; P12 in port - P1F_1 = 0b00000010 ; P11 in port - P1F_0 = 0b00000001 ; P10 in port - - P1F_GET_DPAD = P1F_5 - P1F_GET_BTN = P1F_4 - P1F_GET_NONE = P1F_4 | P1F_5 - - .SB = 0x01 ; Serial IO data buffer - rSB = 0xFF01 - - .SC = 0x02 ; Serial IO control register - rSC = 0xFF02 - - .DIV = 0x04 ; Divider register - rDIV = 0xFF04 - - .TIMA = 0x05 ; Timer counter - rTIMA = 0xFF05 - - .TMA = 0x06 ; Timer modulo - rTMA = 0xFF06 - - .TAC = 0x07 ; Timer control - rTAC = 0xFF07 - - TACF_START = 0b00000100 - TACF_STOP = 0b00000000 - TACF_4KHZ = 0b00000000 - TACF_16KHZ = 0b00000011 - TACF_65KHZ = 0b00000010 - TACF_262KHZ = 0b00000001 - - .IF = 0x0F ; Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL - rIF = 0xFF0F - - .NR10 = 0x10 ; Sound register - rNR10 = 0xFF10 - rAUD1SWEEP = rNR10 - - AUD1SWEEP_UP = 0b00000000 - AUD1SWEEP_DOWN = 0b00001000 - - .NR11 = 0x11 ; Sound register - rNR11 = 0xFF11 - rAUD1LEN = rNR11 - - .NR12 = 0x12 ; Sound register - rNR12 = 0xFF12 - rAUD1ENV = rNR12 - - .NR13 = 0x13 ; Sound register - rNR13 = 0xFF13 - rAUD1LOW = rNR13 - - .NR14 = 0x14 ; Sound register - rNR14 = 0xFF14 - rAUD1HIGH = rNR14 - - .NR21 = 0x16 ; Sound register - rNR21 = 0xFF16 - rAUD2LEN = rNR21 - - .NR22 = 0x17 ; Sound register - rNR22 = 0xFF17 - rAUD2ENV = rNR22 - - .NR23 = 0x18 ; Sound register - rNR23 = 0xFF18 - rAUD2LOW = rNR23 - - .NR24 = 0x19 ; Sound register - rNR24 = 0xFF19 - rAUD2HIGH = rNR24 - - .NR30 = 0x1A ; Sound register - rNR30 = 0xFF1A - rAUD3ENA = rNR30 - - .NR31 = 0x1B ; Sound register - rNR31 = 0xFF1B - rAUD3LEN = rNR31 - - .NR32 = 0x1C ; Sound register - rNR32 = 0xFF1C - rAUD3LEVEL = rNR32 - - .NR33 = 0x1D ; Sound register - rNR33 = 0xFF1D - rAUD3LOW = rNR33 - - .NR34 = 0x1E ; Sound register - rNR34 = 0xFF1E - rAUD3HIGH = rNR34 - - .NR41 = 0x20 ; Sound register - rNR41 = 0xFF20 - rAUD4LEN = rNR41 - - .NR42 = 0x21 ; Sound register - rNR42 = 0xFF21 - rAUD4ENV = rNR42 - - .NR43 = 0x22 ; Sound register - rNR43 = 0xFF22 - rAUD4POLY = rNR43 - - .NR44 = 0x23 ; Sound register - rNR44 = 0xFF23 - rAUD4GO = rNR44 - - .NR50 = 0x24 ; Sound register - rNR50 = 0xFF24 - rAUDVOL = rNR50 - - AUDVOL_VIN_LEFT = 0b10000000 ; SO2 - AUDVOL_VIN_RIGHT = 0b00001000 ; SO1 - - .NR51 = 0x25 ; Sound register - rNR51 = 0xFF25 - rAUDTERM = rNR51 - - AUDTERM_4_LEFT = 0b10000000 - AUDTERM_3_LEFT = 0b01000000 - AUDTERM_2_LEFT = 0b00100000 - AUDTERM_1_LEFT = 0b00010000 - AUDTERM_4_RIGHT = 0b00001000 - AUDTERM_3_RIGHT = 0b00000100 - AUDTERM_2_RIGHT = 0b00000010 - AUDTERM_1_RIGHT = 0b00000001 - - .NR52 = 0x26 ; Sound register - rNR52 = 0xFF26 - rAUDENA = rNR52 - - AUDENA_ON = 0b10000000 - AUDENA_OFF = 0b00000000 ; sets all audio regs to 0! - - .LCDC = 0x40 ; LCD control - rLCDC = 0xFF40 - - LCDCF_OFF = 0b00000000 ; LCD Control Operation - LCDCF_ON = 0b10000000 ; LCD Control Operation - LCDCF_WIN9800 = 0b00000000 ; Window Tile Map Display Select - LCDCF_WIN9C00 = 0b01000000 ; Window Tile Map Display Select - LCDCF_WINOFF = 0b00000000 ; Window Display - LCDCF_WINON = 0b00100000 ; Window Display - LCDCF_BG8800 = 0b00000000 ; BG & Window Tile Data Select - LCDCF_BG8000 = 0b00010000 ; BG & Window Tile Data Select - LCDCF_BG9800 = 0b00000000 ; BG Tile Map Display Select - LCDCF_BG9C00 = 0b00001000 ; BG Tile Map Display Select - LCDCF_OBJ8 = 0b00000000 ; OBJ Construction - LCDCF_OBJ16 = 0b00000100 ; OBJ Construction - LCDCF_OBJOFF = 0b00000000 ; OBJ Display - LCDCF_OBJON = 0b00000010 ; OBJ Display - LCDCF_BGOFF = 0b00000000 ; BG Display - LCDCF_BGON = 0b00000001 ; BG Display - LCDCF_B_ON = 7 - LCDCF_B_WIN9C00 = 6 - LCDCF_B_WINON = 5 - LCDCF_B_BG8000 = 4 - LCDCF_B_BG9C00 = 3 - LCDCF_B_OBJ16 = 2 - LCDCF_B_OBJON = 1 - LCDCF_B_BGON = 0 - - .STAT = 0x41 ; LCD status - rSTAT = 0xFF41 - - STATF_LYC = 0b01000000 ; LYC=LY Coincidence (Selectable) - STATF_MODE10 = 0b00100000 ; Mode 10 - STATF_MODE01 = 0b00010000 ; Mode 01 (V-Blank) - STATF_MODE00 = 0b00001000 ; Mode 00 (H-Blank) - STATF_LYCF = 0b00000100 ; Coincidence Flag - STATF_HBL = 0b00000000 ; H-Blank - STATF_VBL = 0b00000001 ; V-Blank - STATF_OAM = 0b00000010 ; OAM-RAM is used by system - STATF_LCD = 0b00000011 ; Both OAM and VRAM used by system - STATF_BUSY = 0b00000010 ; When set, VRAM access is unsafe - STATF_B_LYC = 6 - STATF_B_MODE10 = 5 - STATF_B_MODE01 = 4 - STATF_B_MODE00 = 3 - STATF_LYCF = 2 - STATF_B_VBL = 0 - STATF_B_OAM = 1 - STATF_B_BUSY = 1 - - .SCY = 0x42 ; Scroll Y - rSCY = 0xFF42 - - .SCX = 0x43 ; Scroll X - rSCX = 0xFF43 - - .LY = 0x44 ; LCDC Y-coordinate - rLY = 0xFF44 - - .LYC = 0x45 ; LY compare - rLYC = 0xFF45 - - .DMA = 0x46 ; DMA transfer - rDMA = 0xFF46 - - .BGP = 0x47 ; BG palette data - rBGP = 0xFF47 - - .OBP0 = 0x48 ; OBJ palette 0 data - rOBP0 = 0xFF48 - - .OBP1 = 0x49 ; OBJ palette 1 data - rOBP1 = 0xFF49 - - .WY = 0x4A ; Window Y coordinate - rWY = 0xFF4A - - .WX = 0x4B ; Window X coordinate - rWX = 0xFF4B - - .KEY1 = 0x4D ; CPU speed - rKEY1 = 0xFF4D - rSPD = rKEY1 - - KEY1F_DBLSPEED = 0b10000000 ; 0=Normal Speed, 1=Double Speed (R) - KEY1F_PREPARE = 0b00000001 ; 0=No, 1=Prepare (R/W) - - .VBK = 0x4F ; VRAM bank - rVBK = 0xFF4F - - .HDMA1 = 0x51 ; DMA control 1 - rHDMA1 = 0xFF51 - - .HDMA2 = 0x52 ; DMA control 2 - rHDMA2 = 0xFF52 - - .HDMA3 = 0x53 ; DMA control 3 - rHDMA3 = 0xFF53 - - .HDMA4 = 0x54 ; DMA control 4 - rHDMA4 = 0xFF54 - - .HDMA5 = 0x55 ; DMA control 5 - rHDMA5 = 0xFF55 - - HDMA5F_MODE_GP = 0b00000000 ; General Purpose DMA (W) - HDMA5F_MODE_HBL = 0b10000000 ; HBlank DMA (W) - - HDMA5F_BUSY = 0b10000000 ; 0=Busy (DMA still in progress), 1=Transfer complete (R) - - .RP = 0x56 ; IR port - rRP = 0xFF56 - - RPF_ENREAD = 0b11000000 - RPF_DATAIN = 0b00000010 ; 0=Receiving IR Signal, 1=Normal - RPF_WRITE_HI = 0b00000001 - RPF_WRITE_LO = 0b00000000 - - .BCPS = 0x68 ; BG color palette specification - rBCPS = 0xFF68 - - BCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing) - - .BCPD = 0x69 ; BG color palette data - rBCPD = 0xFF69 - - .OCPS = 0x6A ; OBJ color palette specification - rOCPS = 0xFF6A - - OCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing) - - .OCPD = 0x6B ; OBJ color palette data - rOCPD = 0xFF6B - - .SVBK = 0x70 ; WRAM bank - rSVBK = 0xFF70 - rSMBK = rSVBK - - rPCM12 = 0xFF76 - - rPCM34 = 0xFF77 - - .IE = 0xFF ; Interrupt enable - rIE = 0xFFFF - - .VBL_IFLAG = 0x01 - .LCD_IFLAG = 0x02 - .TIM_IFLAG = 0x04 - .SIO_IFLAG = 0x08 - .JOY_IFLAG = 0x10 - - IEF_HILO = 0b00010000 ; Transition from High to Low of Pin number P10-P13 - IEF_SERIAL = 0b00001000 ; Serial I/O transfer end - IEF_TIMER = 0b00000100 ; Timer Overflow - IEF_STAT = 0b00000010 ; STAT - IEF_VBLANK = 0b00000001 ; V-Blank - - ;; Flags common to multiple sound channels - - AUDLEN_DUTY_12_5 = 0b00000000 ; 12.5% - AUDLEN_DUTY_25 = 0b01000000 ; 25% - AUDLEN_DUTY_50 = 0b10000000 ; 50% - AUDLEN_DUTY_75 = 0b11000000 ; 75% - - AUDENV_UP = 0b00001000 - AUDENV_DOWN = 0b00000000 - - AUDHIGH_RESTART = 0b10000000 - AUDHIGH_LENGTH_ON = 0b01000000 - AUDHIGH_LENGTH_OFF = 0b00000000 - - ;; OAM related constants - - OAM_COUNT = 40 ; number of OAM entries in OAM RAM - - OAMF_PRI = 0b10000000 ; Priority - OAMF_YFLIP = 0b01000000 ; Y flip - OAMF_XFLIP = 0b00100000 ; X flip - OAMF_PAL0 = 0b00000000 ; Palette number; 0,1 (DMG) - OAMF_PAL1 = 0b00010000 ; Palette number; 0,1 (DMG) - OAMF_BANK0 = 0b00000000 ; Bank number; 0,1 (GBC) - OAMF_BANK1 = 0b00001000 ; Bank number; 0,1 (GBC) - - OAMF_PALMASK = 0b00000111 ; Palette (GBC) - - OAMB_PRI = 7 ; Priority - OAMB_YFLIP = 6 ; Y flip - OAMB_XFLIP = 5 ; X flip - OAMB_PAL1 = 4 ; Palette number; 0,1 (DMG) - OAMB_BANK1 = 3 ; Bank number; 0,1 (GBC) - - ;; GBDK library screen modes - - .G_MODE = 0x01 ; Graphic mode - .T_MODE = 0x02 ; Text mode (bit 2) - .T_MODE_OUT = 0x02 ; Text mode output only - .T_MODE_INOUT = 0x03 ; Text mode with input - .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode - .M_NO_INTERP = 0x08 ; Disables special character interpretation - - ;; Status codes for IO - .IO_IDLE = 0x00 - .IO_SENDING = 0x01 - .IO_RECEIVING = 0x02 - .IO_ERROR = 0x04 - - ;; Type of IO data - .DT_IDLE = 0x66 - .DT_RECEIVING = 0x55 - - ;; Table of routines for modes - .MODE_TABLE = 0x01E0 - - ;; C related - ;; Overheap of a banked call. Used for parameters - ;; = ret + real ret + bank - - .if .NEAR_CALLS - .BANKOV = 2 - - .else - .BANKOV = 6 - - .endif - - .globl __current_bank - .globl __shadow_OAM_base - - ;; Global variables - .globl .mode - - .globl __cpu - - ;; Global routines -; .globl .set_mode ;; don't link mode.o by default - - .globl .reset - - .globl .display_off - - .globl .wait_vbl_done - - ;; Interrupt routines - .globl .add_VBL -; .globl .add_LCD ;; don't link LCD.o by default -; .globl .add_TIM ;; don't link TIM.o by default -; .globl .add_SIO ;; don't link serial.o by default -; .globl .add_JOY ;; don't link JOY.o by default - - ;; Symbols defined at link time - .globl .STACK - .globl _shadow_OAM - .globl .refresh_OAM - - ;; Main user routine - .globl _main - - ;; Macro definitions - -.macro WAIT_STAT ?lbl -lbl: LDH A, (.STAT) - AND #STATF_BUSY ; Check if in LCD modes 0 or 1 - JR NZ, lbl -.endm - -.macro ADD_A_REG16 regH regL - ADD regL - LD regL, A - ADC regH - SUB regL - LD regH, A -.endm - -.macro SIGNED_ADD_A_REG16 regH regL ?lbl - ; If A is negative, we need to subtract 1 from upper byte of 16-bit value - BIT 7, A ; set z if a signed bit is 0 - JR Z, lbl ; if z is set jump to positive - dec regH ; if negative decrement upper byte -lbl: - ADD_A_REG16 regH, regL -.endm - -.macro SIGNED_SUB_A_REG16 regH regL ?lbl - ; negate A then add to 16-bit value - CPL - INC A - SIGNED_ADD_A_REG16 regH, regL -.endm - -.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2 ?lbl3 - ; Multiply DE by A, return result in HL; preserves: BC - LD HL, #0 -lbl1: - SRL A - JR NC, lbl2 - ADD HL, DE -lbl2: - JR Z, lbl3 - SLA E - RL D - JR lbl1 -lbl3: -.endm - diff --git a/gbdk-lib/libc/gb/input.s b/gbdk-lib/libc/gb/input.s @@ -1,647 +0,0 @@ - .include "global.s" - - ;; Note that while gets uses a pointer, the pointer had better - ;; be in non-banked RAM else bad things will happen. - ;; BANKED: checked, imperfect - - .globl .copy_vram - .globl .set_xy_wtt - .globl .mv_sprite - .globl .set_sprite_prop - .globl .set_sprite_tile - .globl .jpad - .globl .padup - - .MINMSPOSX = 0x02 ; In tiles - .MINMSPOSY = 0x0A - .MAXMSPOSX = 0x11 - .MAXMSPOSY = 0x0F - .INIMSPOSX = .MINMSPOSX - .INIMSPOSY = .MINMSPOSY - - .KBDWINPOSY = 0x08 ; In tiles - .KBDSIZE = 0x1006 - - .MSOFFSETX = 0x0C ; In pixels - .MSOFFSETY = 0x14 - - .MINACCEL = 0x0800 - .MAXACCEL = 0x0100 - - .CR = 0x0A ; Unix -; .CR = 0x0D ; Dos - - .globl .tmode_out ; From 'output.s' - .globl .put_char - .globl .del_char - .globl .cury - - .area _INPUT_HEADER (ABS) - - .org .MODE_TABLE+4*.T_MODE_INOUT - JP .tmode_inout - - .module Terminal - - .area _BSS - -.msx: ; Mouse position - .ds 0x01 -.msy: - .ds 0x01 -.msacc: ; Mouse acceleration - .ds 0x02 -.msstate: ; Mouse state - .ds 0x01 -.mschanged: ; Did the mouse move? - .ds 0x01 -.string_len: ; Used length of input buffer - .ds 0x01 - - .area _BASE - - ;; Enter text mode with input -.tmode_inout:: - DI ; Disable interrupts - - ;; Turn the screen off - LDH A,(.LCDC) - AND #LCDCF_ON - JR Z,1$ - - ;; Turn the screen off - CALL .display_off -1$: - - LD A,(.mode) - AND #.T_MODE - CALL Z,.tmode_out - - LD BC,#.tp1 ; Move pointer - LD HL,#0x8000 - LD DE,#.endtp1-.tp1 - CALL .copy_vram - - LD A,#<.MINACCEL ; Acceleration - LD (.msacc),A - LD A,#>.MINACCEL - LD (.msacc+1),A - - ;; Initialize window - LD BC,#.frame_tiles - LD DE,#0x140A ; 0x140A - LD HL,#0 - CALL set_recoded_win_tiles - - LD BC,#.kbdtable - LD DE,#.KBDSIZE - LD HL,#(0x20 * 2 + 2) ; X=2, Y=2 - CALL set_recoded_win_tiles - - LD A,#.MINWNDPOSX - LDH (.WX),A - LD A,#.MAXWNDPOSY ; Hide window - LDH (.WY),A - - XOR A - ;; Initialize sprite - LD C,A ; Sprite 0x00 - LD D,A ; Default sprite properties - CALL .set_sprite_prop - XOR A - LD C,A ; Sprite 0x00 - LD D,A ; Tile 0x00 - CALL .set_sprite_tile - LD A,#0b00101100 - LDH (.OBP0),A - - ;; Turn the screen on - LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGON) - LDH (.LCDC),A - - LD A,#.T_MODE_INOUT - LD (.mode),A - - EI ; Enable interrupts - - RET - -set_recoded_win_tiles:: - LDH A,(.LCDC) - AND #LCDCF_WIN9C00 - JR Z,2$ - LD A,#0x9C - JR 3$ -2$: - LD A,#0x98 -3$: - ADD H - LD H,A - PUSH DE - PUSH HL -4$: - LD A,(BC) - INC BC - PUSH BC - PUSH HL - - LD C,A - LD HL,#(font_current+1) ; font_current+sfont_handle_font - LD A,(HL+) - LD H,(HL) - LD L,A - LD A,(HL+) - AND #3 - CP #2 ; FONT_NOENCODING - JR Z,5$ - INC HL - LD B,#0 - ADD HL,BC - LD C,(HL) -5$: - POP HL - - WAIT_STAT - LD A,C - LD (HL+),A - - POP BC - - DEC D - JR NZ,4$ - - POP HL - POP DE - - LD A,L - ADD #0x20 - LD L,A - ADC H - SUB L - LD H,A - DEC E - - PUSH DE - PUSH HL - JR NZ,4$ - - ADD SP,#4 - RET - - .area _CODE - ;; Prompt the user for a char and return it in A -.get_char: - PUSH BC - PUSH DE - PUSH HL - CALL .show_kbd - CALL .show_mouse -1$: - CALL .track_mouse - CALL .update_mouse - CALL .jpad - LD D,A - AND #.A ; Is A pressed ? - JP Z,1$ - - LD A,(.msy) ; Look for char under the mouse - SUB #.MINMSPOSY - JR Z,12$ - LD E,A - XOR A -11$: - ADD #.MAXMSPOSX-.MINMSPOSX+1 - DEC E - JR NZ,11$ -12$: - LD E,A - LD A,(.msx) - SUB #.MINMSPOSX - ADD E - LD HL,#.kbdtable - LD B,#0x00 - LD C,A - ADD HL,BC - LD B,(HL) - - CALL .hide_mouse - CALL .hide_kbd - LD A,B - - POP HL - POP DE - POP BC - RET - - ;; Prompt the user for a string and store it in (HL) -.get_string: - PUSH BC - PUSH DE - PUSH HL - CALL .show_kbd - CALL .show_bkg - CALL .show_mouse - XOR A - LD (.string_len),A -1$: - CALL .track_mouse - CALL .update_mouse - CALL .jpad - LD D,A - AND #.A ; Is A pressed ? - JP NZ,10$ - LD A,D - AND #.B ; Is B pressed ? - JP NZ,20$ - LD A,D - AND #.SELECT ; Is SELECT pressed ? - JP NZ,30$ - LD A,D - AND #.START ; Is START pressed ? - JR Z,1$ - CALL .padup ; Wait for button to be depressed - - LD A,#.CR - CALL .put_char - LD (HL),#0x00 - CALL .hide_mouse - CALL .hide_bkg - CALL .hide_kbd - POP HL - POP DE - POP BC - RET - -10$: - ;; Insert a character at cursor position - LD A,(.string_len) ; Check buffer length -; CP #.BUFLEN-1 ; Keep 1 char for EOS -; JR Z,13$ - INC A - LD (.string_len),A ; Update it - LD A,(.msy) ; Look for char under the mouse - SUB #.MINMSPOSY - JR Z,12$ - LD E,A - XOR A -11$: - ADD #.MAXMSPOSX-.MINMSPOSX+1 - DEC E - JR NZ,11$ -12$: - LD E,A - LD A,(.msx) - SUB #.MINMSPOSX - ADD E - PUSH HL - LD HL,#.kbdtable - LD B,#0x00 - LD C,A - ADD HL,BC - LD A,(HL) - POP HL - LD (HL+),A ; Add it into input buffer - CALL .put_char ; Print it - CALL .show_bkg ; Ensure the text is not hidden -13$: - CALL .padup ; Wait for button to be depressed - JP 1$ - -20$: - ;; Delete a character at cursor position - LD A,(.string_len) ; Is there any char in the buffer ? - OR A - JR Z,21$ - DEC A ; Yes - LD (.string_len),A ; Update buffer length - DEC HL - CALL .del_char -21$: - CALL .padup ; Wait for button to be depressed - JP 1$ - -30$: - CALL .hide_mouse - CALL .hide_bkg - CALL .hide_kbd - CALL .padup ; Wait for button to be depressed - CALL .show_kbd - CALL .show_bkg - CALL .show_mouse - JP 1$ - -.show_kbd: - PUSH BC - PUSH DE - LDH A,(.LCDC) - OR #LCDCF_WINON ; Window = On - LDH (.LCDC),A - LD A,#.MAXWNDPOSY ; Show window -1$: - BIT 0,A ; Wait for VBL every 2 pixels (slow down) - JR NZ,2$ - LD B,A - CALL .wait_vbl_done - LD A,B -2$: - LDH (.WY),A - CP #.KBDWINPOSY*0x08 - JR Z,99$ - DEC A - JR 1$ -99$: - POP DE - POP BC - RET - -.hide_kbd: - PUSH BC - PUSH DE - LD A,#.KBDWINPOSY*0x08+1 -1$: ; Hide window - BIT 0,A ; Wait for VBL every 2 pixels (slow down) - JR Z,2$ - LD B,A - CALL .wait_vbl_done - LD A,B -2$: - LDH (.WY),A - CP #.MAXWNDPOSY - JR Z,3$ - INC A - JR 1$ -3$: - LDH A,(.LCDC) - AND #~LCDCF_WINON ; Window = Off - LDH (.LCDC),A - POP DE - POP BC - RET - -.show_bkg: - PUSH BC - PUSH DE - LDH A,(.SCY) - LD D,A - LD A,(.cury) - SUB #.KBDWINPOSY-1 - JR C,99$ - JR Z,99$ - SLA A ; A = A * 8 - SLA A - SLA A - SUB D - JR C,99$ - JR Z,99$ - LD C,A - LDH A,(.SCY) -1$: - BIT 0,A ; Wait for VBL every 2 pixels (slow down) - JR Z,2$ - LD B,A - CALL .wait_vbl_done - LD A,B -2$: - INC A - LDH (.SCY),A - DEC C - JR Z,99$ - JR 1$ -99$: - POP DE - POP BC - RET - -.hide_bkg: - LDH A,(.SCY) - OR A - RET Z - PUSH BC - PUSH DE -1$: - BIT 0,A ; Wait for VBL every 2 pixels (slow down) - JR Z,2$ - LD B,A - CALL .wait_vbl_done - LD A,B -2$: - DEC A - LDH (.SCY),A - JR Z,99$ - JR 1$ -99$: - POP DE - POP BC - RET - -.show_mouse: - LD A,#.INIMSPOSX - LD (.msx),A - LD A,#.INIMSPOSY - LD (.msy),A - CALL .set_mouse - LDH A,(.LCDC) - OR #LCDCF_OBJON ; OBJ = On - LDH (.LCDC),A - RET - -.hide_mouse: - LDH A,(.LCDC) - AND #~LCDCF_OBJON ; OBJ = Off - LDH (.LCDC),A - RET - -.track_mouse: - PUSH BC - PUSH DE - PUSH HL - XOR A - LD (.mschanged),A ; Default to no change - CALL .jpad - LD D,A - - LD HL,#.msstate - AND #.UP+.DOWN+.LEFT+.RIGHT - JR NZ,1$ - LD (HL),#0x00 ; Reset state - JP 99$ -1$: - LD A,(HL) - LD (HL),#0x01 ; Set state - OR A ; Was it 0 ? - LD HL,#.msacc ; Acceleration - JR NZ,2$ - ; Yes - LD (HL),#<.MINACCEL - INC HL - LD (HL),#>.MINACCEL - JR 4$ ; Update position -2$: - LD A,(HL+) - LD C, A - LD B,(HL) - DEC BC - LD A,B - OR C - JR Z,3$ - LD (HL),B - DEC HL - LD (HL),C - JP 99$ -3$: ; Set new acceleration to maximum - LD (HL),#>.MAXACCEL - DEC HL - LD (HL),#<.MAXACCEL -4$: ; Update position - LD A,#0x01 - LD (.mschanged),A - LD A,D - AND #.UP ; Is UP pressed ? - JR Z,6$ - LD A,(.msy) - CP #.MINMSPOSY - JR Z,5$ - DEC A - LD (.msy),A - JR 6$ -5$: - LD A,#.MAXMSPOSY - LD (.msy),A -6$: - LD A,D - AND #.DOWN ; Is DOWN pressed ? - JR Z,8$ - LD A,(.msy) - CP #.MAXMSPOSY - JR Z,7$ - INC A - LD (.msy),A - JR 8$ -7$: - LD A,#.MINMSPOSY - LD (.msy),A -8$: - LD A,D - AND #.LEFT ; Is LEFT pressed ? - JR Z,10$ - LD A,(.msx) - CP #.MINMSPOSX - JR Z,9$ - DEC A - LD (.msx),A - JR 10$ -9$: - LD A,#.MAXMSPOSX - LD (.msx),A -10$: - LD A,D - AND #.RIGHT ; Is RIGHT pressed ? - JR Z,99$ - LD A,(.msx) - CP #.MAXMSPOSX - JR Z,11$ - INC A - LD (.msx),A - JR 99$ -11$: - LD A,#.MINMSPOSX - LD (.msx),A -99$: - POP HL - POP DE - POP BC - RET - -.update_mouse: - LD A,(.mschanged) ; Did it change ? - OR A - RET Z ; No -.set_mouse: - PUSH BC - PUSH DE - PUSH HL - LD C,#0x00 ; Sprite 0x00 - LD A,(.msx) - SLA A ; A = A * 8 - SLA A - SLA A - ADD #.MSOFFSETX - LD D,A - LD A,(.msy) - SLA A ; A = A * 8 - SLA A - SLA A - ADD #.MSOFFSETY - LD E,A - CALL .mv_sprite - POP HL - POP DE - POP BC - RET - -_getchar:: ; Banked - LD A,(.mode) - CP #.T_MODE_INOUT - JR Z,1$ - PUSH BC - CALL .tmode_inout - POP BC -1$: - CALL .get_char - LD E,A - RET - -_gets:: ; Banked - LD A,(.mode) - CP #.T_MODE_INOUT - JR Z,1$ - PUSH BC - CALL .tmode_inout - POP BC -1$: - LDA HL,.BANKOV(SP) ; Skip return address - LD A,(HL+) - LD H,(HL) ; HL = s - LD L,A - PUSH HL - CALL .get_string - POP DE - RET - - ;; PENDING: this is unfortunate. Refed from .tmode_inout - .area _BASE -.tp1: - -.pointers: - - ; Tile 0x00 - .byte 0xFF,0xFF,0xFE,0x82,0xFC,0x84,0xFC,0x84,0xFE,0x82,0xFF,0xB1,0xCF,0xC9,0x87,0x87 - -.endtp1: - -.frame_tiles: - .byte 0x1C,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x1D - .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F - .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F - .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F - .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F - .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F - .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F - .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F - .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F - .byte 0x1E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x1F - -.kbdtable: - ;; This is unfortunate. astorgb and rgbasm cant interpert: - ;; .ascii " !\"#$%&'()*+,-./" - ;; so we have to use the hex form here. - .db 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27 - .db 0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F - .ascii "0123456789:" - ;; astorgb recognises the embedded ; as a comment :) - .db 0x3B - .ascii "<=>?" - .ascii "@ABCDEFGHIJKLMNO" - .ascii "PQRSTUVWXYZ[\]^_" - .ascii "`abcdefghijklmno" - .ascii "pqrstuvwxyz{|}~ " diff --git a/gbdk-lib/libc/gb/rand.s b/gbdk-lib/libc/gb/rand.s @@ -1,120 +0,0 @@ -;/*************************************************************************** -; * * -; * Module : rand.s * -; * * -; * Purpose : A rand() generator using the linear congruential method * -; * * -; * Version : 1.01, January 7 1998 * -; * Added _initrand to set seed without recompiling * -; * 1, January 6 1998 * -; * * -; * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) * -; * * -; **************************************************************************/ - - ;; BANKED: checked - - ;; Why use an algorithm for generating random numbers? - ;; - ;; - Given a certain seed value, the same sequence of random numbers is generated - ;; every time. This is a good thing when debugging (reproducible). On the other - ;; hand, you've got 2^16 seed values, each of which will produce a sequence of - ;; numbers that stays different for any of the other sequences for 'an appreciable - ;; time.' (I can't say how long exactly.) - ;; - ;; - The linear congruential method is one of the 'best' random number generators - ;; around. However, this implementation uses a 16 bit accumulator, while at least - ;; 32 bits are needed for a generator that passes all the statistical tests. - ;; Still, I'm relatively confident that this is random enough for even the most - ;; demanding game. - ;; - ;; Compare this to getting random values from one of the hardware registers - ;; (not reproducible, might not have all values). An array might be the best bet - ;; if you don't need a lot of values (or have lots of memory spare), - ;; or if you want values to be within a certain range. - ;; And both would be faster than this. Also, this definitely isn't the fastest - ;; algorithm I know, and certainly for games less strict algorithms might be - ;; appropriate (shift and xor ?). - ;; It's your choice - but if you're doing Monte Carlo physics simulations on the - ;; GameBoy, this is a safe bet! - - .include "global.s" - - .area _BSS -.randhi:: ; Storage for last random number (or seed) - .ds 0x01 -.randlo:: - .ds 0x01 - - .area _CODE - - ;; Random number generator using the linear congruential method - ;; X(n+1) = (a*X(n)+c) mod m - ;; with a = 17, m = 16 and c = $5c93 (arbitrarily) - ;; The seed value is also chosen arbitrarily as $a27e - ;; Ref : D. E. Knuth, "The Art of Computer Programming" , Volume 2 - ;; - ;; Exit conditions - ;; DE = Random number [0,2^16-1] - ;; - ;; Registers used: - ;; A, HL (need not be saved) and DE (return register) - ;; - -_rand:: ; Banked -_randw:: ; Banked - LD A,(.randlo) - LD L,A - LD E,A ; Save randlo - LD A,(.randhi) - LD D,A ; Save randhi - - SLA L ; * 16 - RLA - SLA L - RLA - SLA L - RLA - SLA L - RLA - LD H,A ; Save randhi*16 - - LD A,E ; Old randlo - ADD A,L ; Add randlo*16 - LD L,A ; Save randlo*17 - - LD A,H ; randhi*16 - ADC A,D ; Add old randhi - LD H,A ; Save randhi*17 - - LD A,L ; randlo*17 - ADD A,#0x93 - LD (.randlo),A - LD D,A ; Return register - LD A,H ; randhi*17 - ADC A,#0x5c - LD (.randhi),A - LD E,A ; Return register - - ;; Note D is the low byte,E the high byte. This is intentional because - ;; the high byte can be slightly 'more random' than the low byte, and I presume - ;; most will cast the return value to a uint8_t. As if someone will use this, tha! - RET - - ;; This sets the seed value. Call it whenever you like - ;; - ;; Exit conditions - ;; None - ;; - ;; Registers used: - ;; A, HL (need not be saved) and DE (return register) - ;; - .area _BASE -_initrand:: ; Non banked - LDA HL,2(SP) -.initrand:: - LD A,(HL+) - LD (.randlo),A - LD A,(HL) - LD (.randhi),A - RET diff --git a/gbdk-lib/libc/rules-asxxxx.mk b/gbdk-lib/libc/rules-asxxxx.mk @@ -5,8 +5,14 @@ $(LIB): pre $(OBJ) pre: set-model build-dir +$(BUILD)/%.o: ../%.c + $(CC) $(CFLAGS) -c -o $@ $< + $(BUILD)/%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< +$(BUILD)/%.o: ../%.s + $(AS) -plosgff $@ $< + $(BUILD)/%.o: %.s $(AS) -plosgff $@ $< diff --git a/gbdk-lib/libc/gb/___sdcc_bcall.s b/gbdk-lib/libc/targets/gbz80/___sdcc_bcall.s diff --git a/gbdk-lib/libc/gb/___sdcc_bcall_ehl.s b/gbdk-lib/libc/targets/gbz80/___sdcc_bcall_ehl.s diff --git a/gbdk-lib/libc/targets/gbz80/ap/Makefile b/gbdk-lib/libc/targets/gbz80/ap/Makefile @@ -0,0 +1,52 @@ +# GB specific Makefile + +TOPDIR = ../../../.. + +THIS = ap +PORT = gbz80 + +CSRC = digits.c gprint.c gprintf.c gprintln.c gprintn.c + +ASSRC = cgb.s cgb_palettes.s cgb_compat.s \ + cpy_data.s \ + drawing.s drawing_isr.s color.s \ + f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \ + get_bk_t.s get_data.s get_tile.s \ + get_wi_t.s get_xy_t.s \ + get_addr.s \ + hiramcpy.s init_tt.s input.s \ + pad.s sample.s \ + serial.s set_bk_t.s set_tile.s \ + set_data.s set_prop.s set_spr.s set_wi_t.s set_xy_t.s \ + set_1bit_data.s \ + sgb.s font.s delay.s \ + bgb_emu.s bgb_emu_printf.s \ + nowait.s far_ptr.s \ + lcd.s joy.s tim.s \ + crash_handler.s \ + ___sdcc_bcall_ehl.s ___sdcc_bcall.s \ + mv_spr.s \ + pad_ex.s \ + mode.s clock.s \ + get_t.s set_t.s init_vram.s \ + fill_rect.s fill_rect_bk.s fill_rect_wi.s \ + metasprites.s metasprites_flip.s metasprites_hide.s metasprites_hide_spr.s \ + set_tile_submap.s set_win_tile_submap.s \ + gb_decompress.s gb_decompress_tiles.s \ + heap.s \ + crt0.s + +ifeq ($(ASM),asxxxx) +ASSRC += sfr.s +endif +ifeq ($(ASM),rgbds) +ASSRC += stubs.s +endif + +CRT0 = crt0.s + +include $(TOPDIR)/Makefile.common + +AS = $(AS_GBZ80) + +include ../../../Makefile.platform diff --git a/gbdk-lib/libc/targets/gbz80/ap/crt0.s b/gbdk-lib/libc/targets/gbz80/ap/crt0.s @@ -0,0 +1,503 @@ + .include "global.s" + + ;; **************************************** + ;; Beginning of module + ;; BANKED: checked + .title "Runtime" + .module Runtime + .area _HEADER (ABS) + + ;; RST vectors +; .org 0x00 ; Trap, utilized by crash_handler.h + +; .org 0x08 ; --profile handler utilized by bgb_emu.h + +; .org 0x10 ; empty + +; .org 0x18 ; empty + + .org 0x20 ; RST 0x20 == call HL +.call_hl:: + JP (HL) + + .org 0x28 ; zero up to 256 bytes in C pointed by HL +.MemsetSmall:: + LD (HL+),A + DEC C + JR NZ,.MemsetSmall + ret + + .org 0x30 ; copy up to 256 bytes in C from DE to HL +.MemcpySmall:: + LD A, (DE) + LD (HL+), A + INC DE + DEC C + JR NZ,.MemcpySmall + RET + +; .org 0x38 ; crash handler utilized by crash_handler.h + + ;; Hardware interrupt vectors + .org 0x40 ; VBL +.int_VBL: + PUSH AF + PUSH HL + LD HL,#.int_0x40 + JP .int + +; .org 0x48 ; LCD + +; .org 0x50 ; TIM + +; .org 0x58 ; SIO + +; .org 0x60 ; JOY + +; .org 0x70 + ;; space for drawing.s bit table + + .org 0x80 +.int:: + PUSH BC + PUSH DE +1$: + LD A,(HL+) + OR (HL) + JR Z,.int_tail + PUSH HL + LD A,(HL-) + LD L,(HL) + LD H,A + RST 0x20 ; .call_hl + POP HL + INC HL + JR 1$ +_wait_int_handler:: + ADD SP,#4 +.int_tail: + POP DE + POP BC + POP HL + + ;; we return at least at the beginning of mode 2 + WAIT_STAT + + POP AF + RETI + + ;; VBlank default interrupt routine +__standard_VBL_handler:: +.std_vbl: + LD HL,#.sys_time + INC (HL) + JR NZ,2$ + INC HL + INC (HL) +2$: + CALL .refresh_OAM + + LD A, #1 + LDH (.vbl_done),A + RET + + ;; GameBoy Header + + ;; DO NOT CHANGE... + .org 0x100 +.header: + JR .code_start + + ;; Nintendo logo + .org 0x104 + .byte 0x01,0x10,0xCE,0xEF,0x00,0x00,0x44,0xAA + .byte 0x00,0x74,0x00,0x18,0x11,0x95,0x00,0x34 + .byte 0x00,0x1A,0x00,0xD5,0x00,0x22,0x00,0x69 + .byte 0x6F,0xF6,0xF7,0x73,0x09,0x90,0xE1,0x10 + .byte 0x44,0x40,0x9A,0x90,0xD5,0xD0,0x44,0x30 + .byte 0xA9,0x21,0x5D,0x48,0x22,0xE0,0xF8,0x60 + + ;; Title of the game + .org 0x134 + .asciz "Title" + + .org 0x144 + .byte 0,0,0 + + ;; Cartridge type is ROM only + .org 0x147 + .byte 0 + + ;; ROM size is 32kB + .org 0x148 + .byte 0 + + ;; RAM size is 0kB + .org 0x149 + .byte 0 + + ;; Maker ID + .org 0x14A + .byte 0x00,0x00 + + ;; Version number + .org 0x14C + .byte 0x01 + + ;; Complement check + .org 0x14D + .byte 0x00 + + ;; Checksum + .org 0x14E + .byte 0x00,0x00 + + ;; **************************************** + .org 0x150 + + ;; soft reset: falldown to .code_start +.reset:: +_reset:: + LD A, (__is_GBA) + LD B, A + LD A, (__cpu) + + ;; Initialization code +.code_start:: + DI ; Disable interrupts + LD D, A ; Store CPU type in D + LD E, B + ;; Initialize the stack + LD SP, #.STACK + + LD A, #>_shadow_OAM + LDH (__shadow_OAM_base), A + LD H, A + XOR A + LD L, A + LD C, #(40 << 2) ; 40 entries 4 bytes each + RST 0x28 + + ;; Clear CRT0 global variables + LD HL,#.start_crt_globals + LD C,#(.end_crt_globals - .start_crt_globals) + RST 0x28 + +; LD (.mode),A ; Clearing (.mode) is performed when clearing RAM + + ;; Store CPU type + LD A, D + LD (__cpu), A + CP #.CGB_TYPE + JR NZ, 1$ + XOR A + SRL E + RLA + LD (__is_GBA), A +1$: + + ;; Turn the screen off + CALL .display_off + + XOR A + ;; Initialize the display + LDH (.SCY),A + LDH (.SCX),A + LDH (.STAT),A + LDH (.WY),A + LD A,#0x07 + LDH (.WX),A + + ;; Copy refresh_OAM routine to HRAM + LD DE,#.start_refresh_OAM ; source + LD HL,#.refresh_OAM ; dest + LD C,#(.end_refresh_OAM - .start_refresh_OAM) ; size + RST 0x30 ; call .MemcpySmall + + ;; Clear the OAM by calling refresh_OAM + CALL .refresh_OAM + + ;; Install interrupt routines + LD BC,#.std_vbl + CALL .add_VBL + + ;; Standard color palettes + LD A,#0b11100100 ; Grey 3 = 11 (Black) + ; Grey 2 = 10 (Dark grey) + ; Grey 1 = 01 (Light grey) + ; Grey 0 = 00 (Transparent) + LDH (.BGP),A + LDH (.OBP0),A + LD A,#0b00011011 + LDH (.OBP1),A + + ;; Turn the screen on + LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGOFF) + LDH (.LCDC),A + XOR A + LDH (.IF),A + LD A,#.VBL_IFLAG ; switch on VBlank interrupt only + LDH (.IE),A + + LDH (__current_bank),A ; current bank is 1 at startup + + XOR A + + LD HL,#.sys_time + LD (HL+),A + LD (HL),A + + LDH (.NR52),A ; Turn sound off + + CALL gsinit + + EI ; Enable interrupts + + ;; Call the main function + CALL _main +_exit:: +99$: + HALT + NOP + JR 99$ ; Wait forever + +_set_interrupts:: + DI + LDA HL,2(SP) ; Skip return address + XOR A + LDH (.IF),A ; Clear pending interrupts + LD A,(HL) + EI ; Enable interrupts + LDH (.IE),A ; interrupts are still disabled here + RET + + ;; Copy OAM data to OAM RAM +.start_refresh_OAM: + LDH A,(__shadow_OAM_base) + OR A + RET Z + + LDH (.DMA),A ; Put A into DMA registers + LD A,#0x28 ; We need to wait 160 ns +1$: + DEC A + JR NZ,1$ + RET +.end_refresh_OAM: + + .org .MODE_TABLE + ;; Jump table for modes + RET + + ;; **************************************** + + ;; Ordering of segments for the linker + ;; Code that really needs to be in bank 0 + .area _HOME + ;; Similar to _HOME + .area _BASE + ;; Code + .area _CODE + ;; #pragma bank 0 workaround + .area _CODE_0 + ;; Constant data + .area _LIT +; ;; since _CODE_1 area base address is pre-defined in the linker from 0x4000, +; ;; that moves initializer code and tables out of bank 0 +; .area _CODE_1 + ;; Constant data, used to init _DATA + .area _INITIALIZER + ;; Code, used to init _DATA + .area _GSINIT + .area _GSFINAL + ;; Uninitialised ram data + .area _DATA + .area _BSS + ;; Initialised in ram data + .area _INITIALIZED + ;; For malloc + .area _HEAP + + .area _BSS +.start_crt_globals: + +__cpu:: + .ds 0x01 ; GB type (GB, PGB, CGB) +__is_GBA:: + .ds 0x01 ; detect GBA +.mode:: + .ds 0x01 ; Current mode +.sys_time:: +_sys_time:: + .ds 0x02 ; System time in VBL units +.int_0x40:: + .blkw 0x0A ; 4 interrupt handlers (built-in + user-defined) + +.end_crt_globals: + + .area _HRAM (ABS) + + .org 0xFF90 +__current_bank:: ; Current bank + .ds 0x01 +.vbl_done: + .ds 0x01 ; Is VBL interrupt finished? +__shadow_OAM_base:: + .ds 0x01 + + ;; Runtime library + .area _GSINIT +gsinit:: + LD DE, #l__INITIALIZER + LD A, D + OR E + JR Z, 4$ + LD HL, #s__INITIALIZED + LD BC, #s__INITIALIZER + + SRL D + RR E + JR NC,3$ + LD A,(BC) + LD (HL+),A + INC BC +3$: + INC D + INC E + JR 2$ +1$: + LD A,(BC) + LD (HL+),A + INC BC + LD A,(BC) + LD (HL+),A + INC BC +2$: + DEC E + JR NZ,1$ + DEC D + JR NZ,1$ +4$: + + .area _GSFINAL + ret + + .area _HOME + + ;; Remove interrupt routine in BC from the VBL interrupt list + ;; falldown to .remove_int +.remove_VBL:: + LD HL,#.int_0x40 + + ;; Remove interrupt BC from interrupt list HL if it exists + ;; Abort if a 0000 is found (end of list) +.remove_int:: +1$: + LD A,(HL+) + LD E,A + LD D,(HL) + INC HL + OR D + RET Z ; No interrupt found + + LD A,E + CP C + JR NZ,1$ + LD A,D + CP B + JR NZ,1$ + + LD D,H + LD E,L + DEC DE + DEC DE + + ;; Now do a memcpy from here until the end of the list +2$: + LD A,(HL+) + LD (DE),A + LD B,A + INC DE + LD A,(HL+) + LD (DE),A + INC DE + OR B + RET Z + JR 2$ + + ;; Add interrupt routine in BC to the VBL interrupt list + ;; falldown to .add_int +.add_VBL:: + LD HL,#.int_0x40 + + ;; Add interrupt routine in BC to the interrupt list in HL +.add_int:: +1$: + LD A,(HL+) + OR (HL) + JR Z,2$ + INC HL + JR 1$ +2$: + LD A,B + LD (HL-),A + LD (HL),C + RET + + ;; Wait for VBL interrupt to be finished +.wait_vbl_done:: +_wait_vbl_done:: + ;; Check if the screen is on + LDH A,(.LCDC) + AND #LCDCF_ON + RET Z ; Return if screen is off + XOR A + LDH (.vbl_done),A ; Clear any previous sets of vbl_done +1$: + HALT ; Wait for any interrupt + NOP ; HALT sometimes skips the next instruction + LDH A,(.vbl_done) ; Was it a VBlank interrupt? + ;; Warning: we may lose a VBlank interrupt, if it occurs now + OR A + JR Z,1$ ; No: back to sleep! + RET + +.display_off:: +_display_off:: + ;; Check if the screen is on + LDH A,(.LCDC) + AND #LCDCF_ON + RET Z ; Return if screen is off +1$: ; We wait for the *NEXT* VBL + LDH A,(.LY) + CP #0x92 ; Smaller than or equal to 0x91? + JR NC,1$ ; Loop until smaller than or equal to 0x91 +2$: + LDH A,(.LY) + CP #0x91 ; Bigger than 0x90? + JR C,2$ ; Loop until bigger than 0x90 + + LDH A,(.LCDC) + AND #~LCDCF_ON + LDH (.LCDC),A ; Turn off screen + RET + +_remove_VBL:: + PUSH BC + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) + LD C,A + LD B,(HL) + CALL .remove_VBL + POP BC + RET + +_add_VBL:: + PUSH BC + LDA HL, 4(SP) ; Skip return address and registers + LD A,(HL+) + LD C,A + LD B,(HL) + CALL .add_VBL + POP BC + RET diff --git a/gbdk-lib/libc/targets/gbz80/ap/global.s b/gbdk-lib/libc/targets/gbz80/ap/global.s @@ -0,0 +1,508 @@ + .NEAR_CALLS = 1 ; <near_calls> - tag so that sed can change this + + ;; Changed by astorgb.pl to 1 + __RGBDS__ = 0 + + _VRAM = 0x8000 ; $8000->$9FFF + _VRAM8000 = 0x8000 + _VRAM8800 = 0x8800 + _VRAM9000 = 0x9000 + _SCRN0 = 0x9800 ; $9800->$9BFF + _SCRN1 = 0x9C00 ; $9C00->$9FFF + _SRAM = 0xA000 ; $A000->$BFFF + _RAM = 0xC000 ; $C000->$CFFF / $C000->$DFFF + _RAMBANK = 0xD000 ; $D000->$DFFF + _OAMRAM = 0xFE00 ; $FE00->$FE9F + _IO = 0xFF00 ; $FF00->$FF7F,$FFFF + _AUD3WAVERAM = 0xFF30 ; $FF30->$FF3F + _HRAM = 0xFF80 ; $FF80->$FFFE + + ;; MBC Equates + + .MBC1_ROM_PAGE = 0x2000 ; Address to write to for MBC1 switching + + rRAMG = 0x0000 ; $0000->$1fff + rROMB0 = 0x2000 ; $2000->$2fff + rROMB1 = 0x3000 ; $3000->$3fff - If more than 256 ROM banks are present. + rRAMB = 0x4000 ; $4000->$5fff - Bit 3 enables rumble (if present) + + ;; Keypad + .START = 0x80 + .SELECT = 0x40 + .B = 0x20 + .A = 0x10 + .DOWN = 0x08 + .UP = 0x04 + .LEFT = 0x02 + .RIGHT = 0x01 + + .P14 = 0x10 + .P15 = 0x20 + + ;; Screen dimensions + .MAXCURSPOSX = 0x13 ; In tiles + .MAXCURSPOSY = 0x11 + + .SCREENWIDTH = 0xA0 + .SCREENHEIGHT = 0x90 + .MINWNDPOSX = 0x07 + .MINWNDPOSY = 0x00 + .MAXWNDPOSX = 0xA6 + .MAXWNDPOSY = 0x8F + + ;; Hardware registers + + .P1 = 0x00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10 + rP1 = 0xFF00 + + P1F_5 = 0b00100000 ; P15 out port, set to 0 to get buttons + P1F_4 = 0b00010000 ; P14 out port, set to 0 to get dpad + P1F_3 = 0b00001000 ; P13 in port + P1F_2 = 0b00000100 ; P12 in port + P1F_1 = 0b00000010 ; P11 in port + P1F_0 = 0b00000001 ; P10 in port + + P1F_GET_DPAD = 0b00100000 + P1F_GET_BTN = 0b00010000 + P1F_GET_NONE = 0b00110000 + + .SB = 0x01 ; Serial IO data buffer + rSB = 0xFF01 + + .SC = 0x02 ; Serial IO control register + rSC = 0xFF02 + + .DIV = 0x04 ; Divider register + rDIV = 0xFF04 + + .TIMA = 0x05 ; Timer counter + rTIMA = 0xFF05 + + .TMA = 0x06 ; Timer modulo + rTMA = 0xFF06 + + .TAC = 0x07 ; Timer control + rTAC = 0xFF07 + + TACF_START = 0b00000100 + TACF_STOP = 0b00000000 + TACF_4KHZ = 0b00000000 + TACF_16KHZ = 0b00000011 + TACF_65KHZ = 0b00000010 + TACF_262KHZ = 0b00000001 + + .IF = 0x0F ; Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL + rIF = 0xFF0F + + .NR10 = 0x10 ; Sound register + rNR10 = 0xFF10 + rAUD1SWEEP = 0xFF10 + + AUD1SWEEP_UP = 0b00000000 + AUD1SWEEP_DOWN = 0b00001000 + + .NR11 = 0x11 ; Sound register + rNR11 = 0xFF11 + rAUD1LEN = 0xFF11 + + .NR12 = 0x12 ; Sound register + rNR12 = 0xFF12 + rAUD1ENV = 0xFF12 + + .NR13 = 0x13 ; Sound register + rNR13 = 0xFF13 + rAUD1LOW = 0xFF13 + + .NR14 = 0x14 ; Sound register + rNR14 = 0xFF14 + rAUD1HIGH = 0xFF14 + + .NR21 = 0x16 ; Sound register + rNR21 = 0xFF16 + rAUD2LEN = 0xFF16 + + .NR22 = 0x17 ; Sound register + rNR22 = 0xFF17 + rAUD2ENV = 0xFF17 + + .NR23 = 0x18 ; Sound register + rNR23 = 0xFF18 + rAUD2LOW = 0xFF18 + + .NR24 = 0x19 ; Sound register + rNR24 = 0xFF19 + rAUD2HIGH = 0xFF19 + + .NR30 = 0x1A ; Sound register + rNR30 = 0xFF1A + rAUD3ENA = 0xFF1A + + .NR31 = 0x1B ; Sound register + rNR31 = 0xFF1B + rAUD3LEN = 0xFF1B + + .NR32 = 0x1C ; Sound register + rNR32 = 0xFF1C + rAUD3LEVEL = 0xFF1C + + .NR33 = 0x1D ; Sound register + rNR33 = 0xFF1D + rAUD3LOW = 0xFF1D + + .NR34 = 0x1E ; Sound register + rNR34 = 0xFF1E + rAUD3HIGH = 0xFF1E + + .NR41 = 0x20 ; Sound register + rNR41 = 0xFF20 + rAUD4LEN = 0xFF20 + + .NR42 = 0x21 ; Sound register + rNR42 = 0xFF21 + rAUD4ENV = 0xFF21 + + .NR43 = 0x22 ; Sound register + rNR43 = 0xFF22 + rAUD4POLY = 0xFF22 + + .NR44 = 0x23 ; Sound register + rNR44 = 0xFF23 + rAUD4GO = 0xFF23 + + .NR50 = 0x24 ; Sound register + rNR50 = 0xFF24 + rAUDVOL = 0xFF24 + + AUDVOL_VIN_LEFT = 0b10000000 ; SO2 + AUDVOL_VIN_RIGHT = 0b00001000 ; SO1 + + .NR51 = 0x25 ; Sound register + rNR51 = 0xFF25 + rAUDTERM = 0xFF25 + + AUDTERM_4_LEFT = 0b10000000 + AUDTERM_3_LEFT = 0b01000000 + AUDTERM_2_LEFT = 0b00100000 + AUDTERM_1_LEFT = 0b00010000 + AUDTERM_4_RIGHT = 0b00001000 + AUDTERM_3_RIGHT = 0b00000100 + AUDTERM_2_RIGHT = 0b00000010 + AUDTERM_1_RIGHT = 0b00000001 + + .NR52 = 0x26 ; Sound register + rNR52 = 0xFF26 + rAUDENA = 0xFF26 + + AUDENA_ON = 0b10000000 + AUDENA_OFF = 0b00000000 ; sets all audio regs to 0! + + .LCDC = 0x4E ; LCD control + rLCDC = 0xFF4E + + LCDCF_OFF = 0b00000000 ; LCD Control Operation + LCDCF_ON = 0b00000001 ; LCD Control Operation + LCDCF_WIN9800 = 0b00000000 ; Window Tile Map Display Select + LCDCF_WIN9C00 = 0b00000010 ; Window Tile Map Display Select + LCDCF_WINOFF = 0b00000000 ; Window Display + LCDCF_WINON = 0b00000100 ; Window Display + LCDCF_BG8800 = 0b00000000 ; BG & Window Tile Data Select + LCDCF_BG8000 = 0b00001000 ; BG & Window Tile Data Select + LCDCF_BG9800 = 0b00000000 ; BG Tile Map Display Select + LCDCF_BG9C00 = 0b00010000 ; BG Tile Map Display Select + LCDCF_OBJ8 = 0b00000000 ; OBJ Construction + LCDCF_OBJ16 = 0b00100000 ; OBJ Construction + LCDCF_OBJOFF = 0b00000000 ; OBJ Display + LCDCF_OBJON = 0b01000000 ; OBJ Display + LCDCF_BGOFF = 0b00000000 ; BG Display + LCDCF_BGON = 0b10000000 ; BG Display + LCDCF_B_ON = 0 + LCDCF_B_WIN9C00 = 1 + LCDCF_B_WINON = 2 + LCDCF_B_BG8000 = 3 + LCDCF_B_BG9C00 = 4 + LCDCF_B_OBJ16 = 5 + LCDCF_B_OBJON = 6 + LCDCF_B_BGON = 7 + + .STAT = 0x41 ; LCD status + rSTAT = 0xFF41 + + STATF_LYC = 0b00000010 ; LYC=LY Coincidence (Selectable) + STATF_MODE10 = 0b00000100 ; Mode 10 + STATF_MODE01 = 0b00001000 ; Mode 01 (V-Blank) + STATF_MODE00 = 0b00010000 ; Mode 00 (H-Blank) + STATF_LYCF = 0b00100000 ; Coincidence Flag + STATF_HBL = 0b00000000 ; H-Blank + STATF_VBL = 0b10000000 ; V-Blank + STATF_OAM = 0b01000000 ; OAM-RAM is used by system + STATF_LCD = 0b11000000 ; Both OAM and VRAM used by system + STATF_BUSY = 0b01000000 ; When set, VRAM access is unsafe + STATF_B_LYC = 1 + STATF_B_MODE10 = 2 + STATF_B_MODE01 = 3 + STATF_B_MODE00 = 4 + STATF_B_LYCF = 5 + STATF_B_VBL = 7 + STATF_B_OAM = 6 + STATF_B_BUSY = 6 + + .SCY = 0x42 ; Scroll Y + rSCY = 0xFF42 + + .SCX = 0x43 ; Scroll X + rSCX = 0xFF43 + + .LY = 0x44 ; LCDC Y-coordinate + rLY = 0xFF44 + + .LYC = 0x45 ; LY compare + rLYC = 0xFF45 + + .DMA = 0x46 ; DMA transfer + rDMA = 0xFF46 + + .BGP = 0x47 ; BG palette data + rBGP = 0xFF47 + + .OBP0 = 0x48 ; OBJ palette 0 data + rOBP0 = 0xFF48 + + .OBP1 = 0x49 ; OBJ palette 1 data + rOBP1 = 0xFF49 + + .WY = 0x4A ; Window Y coordinate + rWY = 0xFF4A + + .WX = 0x4B ; Window X coordinate + rWX = 0xFF4B + + .KEY1 = 0x4D ; CPU speed + rKEY1 = 0xFF4D + rSPD = 0xFF4D + + KEY1F_DBLSPEED = 0b10000000 ; 0=Normal Speed, 1=Double Speed (R) + KEY1F_PREPARE = 0b00000001 ; 0=No, 1=Prepare (R/W) + + .VBK = 0x4F ; VRAM bank + rVBK = 0xFF4F + + .HDMA1 = 0x51 ; DMA control 1 + rHDMA1 = 0xFF51 + + .HDMA2 = 0x52 ; DMA control 2 + rHDMA2 = 0xFF52 + + .HDMA3 = 0x53 ; DMA control 3 + rHDMA3 = 0xFF53 + + .HDMA4 = 0x54 ; DMA control 4 + rHDMA4 = 0xFF54 + + .HDMA5 = 0x55 ; DMA control 5 + rHDMA5 = 0xFF55 + + HDMA5F_MODE_GP = 0b00000000 ; General Purpose DMA (W) + HDMA5F_MODE_HBL = 0b10000000 ; HBlank DMA (W) + + HDMA5F_BUSY = 0b10000000 ; 0=Busy (DMA still in progress), 1=Transfer complete (R) + + .RP = 0x56 ; IR port + rRP = 0xFF56 + + RPF_ENREAD = 0b11000000 + RPF_DATAIN = 0b00000010 ; 0=Receiving IR Signal, 1=Normal + RPF_WRITE_HI = 0b00000001 + RPF_WRITE_LO = 0b00000000 + + .BCPS = 0x68 ; BG color palette specification + rBCPS = 0xFF68 + + BCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing) + + .BCPD = 0x69 ; BG color palette data + rBCPD = 0xFF69 + + .OCPS = 0x6A ; OBJ color palette specification + rOCPS = 0xFF6A + + OCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing) + + .OCPD = 0x6B ; OBJ color palette data + rOCPD = 0xFF6B + + .SVBK = 0x70 ; WRAM bank + rSVBK = 0xFF70 + rSMBK = 0xFF70 + + rPCM12 = 0xFF76 + + rPCM34 = 0xFF77 + + .IE = 0xFF ; Interrupt enable + rIE = 0xFFFF + + .VBL_IFLAG = 0x01 + .LCD_IFLAG = 0x02 + .TIM_IFLAG = 0x04 + .SIO_IFLAG = 0x08 + .JOY_IFLAG = 0x10 + + IEF_HILO = 0b00010000 ; Transition from High to Low of Pin number P10-P13 + IEF_SERIAL = 0b00001000 ; Serial I/O transfer end + IEF_TIMER = 0b00000100 ; Timer Overflow + IEF_STAT = 0b00000010 ; STAT + IEF_VBLANK = 0b00000001 ; V-Blank + + ;; Flags common to multiple sound channels + + AUDLEN_DUTY_12_5 = 0b00000000 ; 12.5% + AUDLEN_DUTY_25 = 0b01000000 ; 25% + AUDLEN_DUTY_50 = 0b10000000 ; 50% + AUDLEN_DUTY_75 = 0b11000000 ; 75% + + AUDENV_UP = 0b00001000 + AUDENV_DOWN = 0b00000000 + + AUDHIGH_RESTART = 0b10000000 + AUDHIGH_LENGTH_ON = 0b01000000 + AUDHIGH_LENGTH_OFF = 0b00000000 + + ;; OAM related constants + + OAM_COUNT = 40 ; number of OAM entries in OAM RAM + + OAMF_PRI = 0b10000000 ; Priority + OAMF_YFLIP = 0b01000000 ; Y flip + OAMF_XFLIP = 0b00100000 ; X flip + OAMF_PAL0 = 0b00000000 ; Palette number; 0,1 (DMG) + OAMF_PAL1 = 0b00010000 ; Palette number; 0,1 (DMG) + OAMF_BANK0 = 0b00000000 ; Bank number; 0,1 (GBC) + OAMF_BANK1 = 0b00001000 ; Bank number; 0,1 (GBC) + + OAMF_PALMASK = 0b00000111 ; Palette (GBC) + + OAMB_PRI = 7 ; Priority + OAMB_YFLIP = 6 ; Y flip + OAMB_XFLIP = 5 ; X flip + OAMB_PAL1 = 4 ; Palette number; 0,1 (DMG) + OAMB_BANK1 = 3 ; Bank number; 0,1 (GBC) + + ;; CPU detection + .DMG_TYPE = 0x01 ; Original GB or Super GB + .MGB_TYPE = 0xFF ; Pocket GB or Super GB 2 + .CGB_TYPE = 0x11 ; Color GB + + ;; GBDK library screen modes + + .G_MODE = 0x01 ; Graphic mode + .T_MODE = 0x02 ; Text mode (bit 2) + .T_MODE_OUT = 0x02 ; Text mode output only + .T_MODE_INOUT = 0x03 ; Text mode with input + .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode + .M_NO_INTERP = 0x08 ; Disables special character interpretation + + ;; Status codes for IO + .IO_IDLE = 0x00 + .IO_SENDING = 0x01 + .IO_RECEIVING = 0x02 + .IO_ERROR = 0x04 + + ;; Type of IO data + .DT_IDLE = 0x66 + .DT_RECEIVING = 0x55 + + ;; Table of routines for modes + .MODE_TABLE = 0x01E0 + + ;; C related + ;; Overheap of a banked call. Used for parameters + ;; = ret + real ret + bank + + .if .NEAR_CALLS + .BANKOV = 2 + + .else + .BANKOV = 6 + + .endif + + .globl __current_bank + .globl __shadow_OAM_base + + ;; Global variables + .globl .mode + + .globl __cpu + .globl __is_GBA + + ;; Global routines +; .globl .set_mode ;; don't link mode.o by default + + .globl .reset + + .globl .display_off + + .globl .wait_vbl_done + + ;; Interrupt routines + .globl .add_VBL +; .globl .add_LCD ;; don't link LCD.o by default +; .globl .add_TIM ;; don't link TIM.o by default +; .globl .add_SIO ;; don't link serial.o by default +; .globl .add_JOY ;; don't link JOY.o by default + + ;; Symbols defined at link time + .globl .STACK + .globl _shadow_OAM + .globl .refresh_OAM + + ;; Main user routine + .globl _main + + ;; Macro definitions + +.macro WAIT_STAT ?lbl +lbl: LDH A, (.STAT) + AND #STATF_BUSY ; Check if in LCD modes 0 or 1 + JR NZ, lbl +.endm + +.macro ADD_A_REG16 regH regL + ADD regL + LD regL, A + ADC regH + SUB regL + LD regH, A +.endm + +.macro SIGNED_ADD_A_REG16 regH regL ?lbl + ; If A is negative, we need to subtract 1 from upper byte of 16-bit value + BIT 7, A ; set z if a signed bit is 0 + JR Z, lbl ; if z is set jump to positive + dec regH ; if negative decrement upper byte +lbl: + ADD_A_REG16 regH, regL +.endm + +.macro SIGNED_SUB_A_REG16 regH regL ?lbl + ; negate A then add to 16-bit value + CPL + INC A + SIGNED_ADD_A_REG16 regH, regL +.endm + +.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2 ?lbl3 + ; Multiply DE by A, return result in HL; preserves: BC + LD HL, #0 +lbl1: + SRL A + JR NC, lbl2 + ADD HL, DE +lbl2: + JR Z, lbl3 + SLA E + RL D + JR lbl1 +lbl3: +.endm + diff --git a/gbdk-lib/libc/targets/gbz80/ap/sfr.s b/gbdk-lib/libc/targets/gbz80/ap/sfr.s @@ -0,0 +1,110 @@ +__VRAM = 0x8000 +__VRAM8000 = 0x8000 +__VRAM8800 = 0x8800 +__VRAM9000 = 0x9000 +__SCRN0 = 0x9800 +__SCRN1 = 0x9C00 +__SRAM = 0xA000 +__RAM = 0xC000 +__RAMBANK = 0xD000 +__OAMRAM = 0xFE00 +__IO = 0xFF00 +__AUD3WAVERAM = 0xFF30 +__HRAM = 0xFF80 + +.globl __VRAM, __VRAM8000, __VRAM8800, __VRAM9000, __SCRN0, __SCRN1, __SRAM, __RAM, __RAMBANK, __OAMRAM, __IO, __AUD3WAVERAM, __HRAM + +_rRAMG = 0x0000 +_rROMB0 = 0x2000 +_rROMB1 = 0x3000 +_rRAMB = 0x4000 + +.globl _rRAMG, _rROMB0, _rROMB1, _rRAMB + +_P1_REG = 0xFF00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10 +_SB_REG = 0xFF01 ; Serial IO data buffer +_SC_REG = 0xFF02 ; Serial IO control register +_DIV_REG = 0xFF04 ; Divider register +_TIMA_REG = 0xFF05 ; Timer counter +_TMA_REG = 0xFF06 ; Timer modulo +_TAC_REG = 0xFF07 ; Timer control +_IF_REG = 0xFF0F ; Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL +_NR10_REG = 0xFF10 ; Sound register +_NR11_REG = 0xFF11 ; Sound register +_NR12_REG = 0xFF12 ; Sound register +_NR13_REG = 0xFF13 ; Sound register +_NR14_REG = 0xFF14 ; Sound register +_NR21_REG = 0xFF16 ; Sound register +_NR22_REG = 0xFF17 ; Sound register +_NR23_REG = 0xFF18 ; Sound register +_NR24_REG = 0xFF19 ; Sound register +_NR30_REG = 0xFF1A ; Sound register +_NR31_REG = 0xFF1B ; Sound register +_NR32_REG = 0xFF1C ; Sound register +_NR33_REG = 0xFF1D ; Sound register +_NR34_REG = 0xFF1E ; Sound register +_NR41_REG = 0xFF20 ; Sound register +_NR42_REG = 0xFF21 ; Sound register +_NR43_REG = 0xFF22 ; Sound register +_NR44_REG = 0xFF23 ; Sound register +_NR50_REG = 0xFF24 ; Sound register +_NR51_REG = 0xFF25 ; Sound register +_NR52_REG = 0xFF26 ; Sound register +_PCM_SAMPLE = 0xFF30 ; PCM wave pattern +_LCDC_REG = 0xFF4E ; LCD control +_STAT_REG = 0xFF41 ; LCD status +_SCY_REG = 0xFF42 ; Scroll Y +_SCX_REG = 0xFF43 ; Scroll X +_LY_REG = 0xFF44 ; LCDC Y-coordinate +_LYC_REG = 0xFF45 ; LY compare +_DMA_REG = 0xFF46 ; DMA transfer +_BGP_REG = 0xFF47 ; BG palette data +_OBP0_REG = 0xFF48 ; OBJ palette 0 data +_OBP1_REG = 0xFF49 ; OBJ palette 1 data +_WY_REG = 0xFF4A ; Window Y coordinate +_WX_REG = 0xFF4B ; Window X coordinate +_KEY1_REG = 0xFF4D ; CPU speed +_VBK_REG = 0xFF4F ; VRAM bank +_HDMA1_REG = 0xFF51 ; DMA control 1 +_HDMA2_REG = 0xFF52 ; DMA control 2 +_HDMA3_REG = 0xFF53 ; DMA control 3 +_HDMA4_REG = 0xFF54 ; DMA control 4 +_HDMA5_REG = 0xFF55 ; DMA control 5 +_RP_REG = 0xFF56 ; IR port +_BCPS_REG = 0xFF68 ; BG color palette specification +_BCPD_REG = 0xFF69 ; BG color palette data +_OCPS_REG = 0xFF6A ; OBJ color palette specification +_OCPD_REG = 0xFF6B ; OBJ color palette data +_SVBK_REG = 0xFF70 ; WRAM bank +_PCM12_REG = 0xFF76 ; Sound channel 1&2 PCM amplitude (R) +_PCM34_REG = 0xFF77 ; Sound channel 3&4 PCM amplitude (R) +_IE_REG = 0xFFFF ; Interrupt enable + +.globl _P1_REG +.globl _SB_REG, _SC_REG +.globl _DIV_REG +.globl _TIMA_REG, _TMA_REG, _TAC_REG +.globl _IF_REG +.globl _NR10_REG, _NR11_REG, _NR12_REG, _NR13_REG, _NR14_REG +.globl _NR21_REG, _NR22_REG, _NR23_REG, _NR24_REG +.globl _NR30_REG, _NR31_REG, _NR32_REG, _NR33_REG, _NR34_REG +.globl _NR41_REG, _NR42_REG, _NR43_REG, _NR44_REG +.globl _NR50_REG, _NR51_REG, _NR52_REG +.globl _PCM_SAMPLE +.globl _LCDC_REG +.globl _STAT_REG +.globl _SCY_REG, _SCX_REG +.globl _LY_REG, _LYC_REG +.globl _DMA_REG +.globl _BGP_REG +.globl _OBP0_REG, _OBP1_REG +.globl _WY_REG, _WX_REG +.globl _KEY1_REG +.globl _VBK_REG +.globl _HDMA1_REG, _HDMA2_REG, _HDMA3_REG, _HDMA4_REG, _HDMA5_REG +.globl _RP_REG +.globl _BCPS_REG, _BCPD_REG +.globl _OCPS_REG, _OCPD_REG +.globl _SVBK_REG +.globl _PCM12_REG, _PCM34_REG +.globl _IE_REG + diff --git a/gbdk-lib/libc/gb/bgb_emu.s b/gbdk-lib/libc/targets/gbz80/bgb_emu.s diff --git a/gbdk-lib/libc/gb/bgb_emu_printf.s b/gbdk-lib/libc/targets/gbz80/bgb_emu_printf.s diff --git a/gbdk-lib/libc/gb/cgb.s b/gbdk-lib/libc/targets/gbz80/cgb.s diff --git a/gbdk-lib/libc/gb/cgb_compat.s b/gbdk-lib/libc/targets/gbz80/cgb_compat.s diff --git a/gbdk-lib/libc/targets/gbz80/cgb_palettes.s b/gbdk-lib/libc/targets/gbz80/cgb_palettes.s @@ -0,0 +1,78 @@ + .include "global.s" + + .title "CGB support" + .module CGB + + .area _CODE + +_set_sprite_palette:: ; Non-banked + PUSH BC + LD C,#.OCPS + JR .set_palette + +_set_bkg_palette:: ; Non-banked + PUSH BC + LD C,#.BCPS + +.set_palette:: + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; first_palette + ADD A ; A *= 8 + ADD A + ADD A + OR #0x80 ; Set auto-increment + LDH (C),A + INC C + LD A,(HL+) ; D = nb_palettes + ADD A ; A *= 8 + ADD A + ADD A + LD B,A ; Number of bytes + LD A,(HL+) ; rgb_data + LD H,(HL) + LD L,A +1$: + WAIT_STAT + + LD A,(HL+) + LDH (C),A + DEC B + JR NZ,1$ + + POP BC + RET + +_set_sprite_palette_entry:: ; Banked + PUSH BC + LD C,#.OCPS + JR .set_palette_entry + +_set_bkg_palette_entry:: ; Banked + PUSH BC + LD C,#.BCPS + +.set_palette_entry:: + LDA HL,4(SP); Skip return address and registers + LD A,(HL+) ; first_palette + ADD A ; A *= 4 + ADD A + LD B,A + LD A,(HL+) ; pal_entry + ADD B ; A += first_palette * 4 + ADD A ; A *= 2 + OR #0x80 ; Set auto-increment + LDH (C),A + INC C + LD A,(HL+) ; rgb_data + LD H,(HL) + LD L,A + + WAIT_STAT + + LD A,L + LDH (C),A + LD A,H + LDH (C),A + + POP BC + RET diff --git a/gbdk-lib/libc/gb/clock.s b/gbdk-lib/libc/targets/gbz80/clock.s diff --git a/gbdk-lib/libc/targets/gbz80/color.s b/gbdk-lib/libc/targets/gbz80/color.s @@ -0,0 +1,24 @@ + .include "global.s" + + ;; Data + .area _BSS + ;; Foreground drawing colour +.fg_colour:: + .ds 1 + ;; Background drawing colour +.bg_colour:: + .ds 1 + ;; Drawing mode (.SOILD etc) +.draw_mode:: + .ds 1 + + .area _BASE +_color:: + LDA HL,2(SP) ; Skip return address and registers + LD A,(HL+) ; A = Foreground + LD (.fg_colour),a + LD A,(HL+) + LD (.bg_colour),a + LD A,(HL) + LD (.draw_mode),a + RET diff --git a/gbdk-lib/libc/gb/cpy_data.s b/gbdk-lib/libc/targets/gbz80/cpy_data.s diff --git a/gbdk-lib/libc/gb/crash_handler.s b/gbdk-lib/libc/targets/gbz80/crash_handler.s diff --git a/gbdk-lib/libc/gb/delay.s b/gbdk-lib/libc/targets/gbz80/delay.s diff --git a/gbdk-lib/libc/gb/digits.c b/gbdk-lib/libc/targets/gbz80/digits.c diff --git a/gbdk-lib/libc/targets/gbz80/drawing.s b/gbdk-lib/libc/targets/gbz80/drawing.s @@ -0,0 +1,1770 @@ +;; Optimised Drawing library +;; By Jon Fuge (jonny@q-continuum.demon.co.uk) based on original file +;; Updates +;; 990223 Michael Removed mod_col, splitting it up into +;; fg_colour, bg_colour, and draw_mode +;; Note: some optimisations are available with unneded PUSH DE/POP DE's + + .include "global.s" + + .globl .init_vram + .globl .copy_vram + + .globl .drawing_lcd, .drawing_vbl + .globl .bg_colour, .fg_colour, .draw_mode + + .M_SOLID = 0x00 + .M_OR = 0x01 + .M_XOR = 0x02 + .M_AND = 0x03 + + ;; Format of mod_col + ;; 7 6 5 4 3 2 1 0 + ;; mode fg bg + + .area _DRAW_HEADER (ABS) + + .org 0x70 +.drawing_bits_tbl:: + .byte 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01 + .byte 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 + + .org .MODE_TABLE+4*.G_MODE + JP .gmode + + .module Drawing1 + + ;; Data + .area _BSS + ;; Fill style +.style: + .ds 0x01 + ;; Various varibles +.x_s: + .ds 2 +.y_s: + .ds 2 +.delta_x: + .ds 1 +.delta_y: + .ds 1 +.l_inc: + .ds 1 +.l_d: + .ds 2 +.dinc1: + .ds 2 +.dinc2: + .ds 2 +.tx: + .ds 1 +.ty: + .ds 1 + + .area _BASE + ;; Enter graphic mode +.gmode:: + DI ; Disable interrupts + + ;; Turn the screen off + LDH A,(.LCDC) + AND #LCDCF_ON + JR Z,1$ + + ;; Turn the screen off + CALL .display_off +1$: + LD HL,#0x8000+0x10*0x10 + LD DE,#0x1800-0x18*0x10 + LD B,#0x00 + CALL .init_vram ; Init the charset at 0x8000 + + ;; Install interrupt routines + LD BC,#.drawing_vbl + CALL .add_VBL + LD BC,#.drawing_lcd + CALL .add_LCD + + LD A,#72 ; Set line at which LCD interrupt occurs + LDH (.LYC),A + + LD A,#STATF_LYC + LDH (.STAT),A + + LDH A,(.IE) + OR #.LCD_IFLAG ; Enable LCD interrupt + LDH (.IE),A + + ;; (9*20) = 180 tiles are used in the upper part of the screen + ;; (9*20) = 180 tiles are used in the lower part of the screen + ;; => We have 24 tiles free + ;; We keep 16 at 0x8000->0x80FF, and 8 at 0x9780->97FF + + LD HL,#0x9800 + LD A,#0x10 ; Keep 16 tiles free + LD BC,#12 ; 12 unused columns + LD E,#18 ; 18 lines +2$: + LD D,#20 ; 20 used columns +3$: + LD (HL+),A + INC A + DEC D + JR NZ,3$ + ADD HL,BC + DEC E + JR NZ,2$ + + ;; Turn the screen on + LDH A,(.LCDC) + OR #(LCDCF_ON | LCDCF_BG8000 | LCDCF_BGON) + AND #~LCDCF_BG9C00 ; BG Bank = 0x9800 + LDH (.LCDC),A + + LD A,#.G_MODE + LD (.mode),A + + ;; Setup the default colours and draw modes + LD A,#.M_SOLID + LD (.draw_mode),A + LD A,#0x03 ; Black + LD (.fg_colour),A + LD A,#0x00 ; White + LD (.bg_colour),A + + EI ; Enable interrupts + + RET + + ;; Draw a full-screen image at (BC) +.draw_image:: + LD HL,#0x8000+0x10*0x10 + LD DE,#0x1680 + CALL .copy_vram ; Move the charset + RET + + ;; Replace tile data at (B,C) with data at DE and store old value at HL +.switch_data:: + PUSH DE ; Save src + PUSH HL ; Save dst + LD L,B + SLA L + SLA L + SLA L + LD H,#0x00 + ADD HL,HL + LD D,H + LD E,L + + LD HL,#.y_table + SLA C + SLA C + SLA C + LD B,#0x00 + ADD HL,BC + ADD HL,BC + LD A,(HL+) + LD H,(HL) + LD L,A + ADD HL,DE + + LD B,H ; BC = src + LD C,L + POP HL ; HL = dst + PUSH BC ; Save dst + LD A,H + OR L + JR Z,1$ + LD DE,#0x10 + CALL .copy_vram +1$: + POP HL ; HL = dst + POP BC ; BC = src + LD A,B + OR C + JR Z,2$ + LD DE,#0x10 + CALL .copy_vram +2$: + RET + + .area _CODE + ;; Advance the cursor +.adv_gcurs:: + PUSH HL + LD HL,#.tx ; X coordinate + LD A,#.MAXCURSPOSX + CP (HL) + JR Z,1$ + INC (HL) + JR 99$ +1$: + LD (HL),#0x00 + LD HL,#.ty ; Y coordinate + LD A,#.MAXCURSPOSY + CP (HL) + JR Z,2$ + INC (HL) + JR 99$ +2$: + LD (HL),#0x00 +99$: + POP HL + RET + + ;; Draw a circle from (B,C) with radius D +.circle:: + LD A,B ;Store center values + LD (.x_s),A + LD A,C + LD (.y_s),A + + XOR A + LD (.x_s+1),A + LD A,D + LD (.y_s+1),A + CPL + LD L,A + LD H,#0xFF + INC HL + LD BC,#0 + ADD HL,BC + LD A,L + LD (.l_d+1),A + LD A,H + LD (.l_d),A + +cloop$: + LD A,(.x_s+1) + LD B,A + LD A,(.y_s+1) + SUB B + RET C + + LD A,(.style) + OR A + CALL Z,.circplot + + LD A,(.l_d) + BIT 7,A + JR Z,ycirc$ + + LD A,(.style) + OR A + CALL NZ,.horlin + LD A,(.x_s+1) + INC A + LD (.x_s+1),A + LD A,(.l_d) + LD B,A + LD A,(.l_d+1) + LD C,A + LD H,#0 + LD A,(.x_s+1) + LD L,A + ADD HL,HL + ADD HL,HL + ADD HL,BC + LD BC,#6 + ADD HL,BC + LD A,H + LD (.l_d),A + LD A,L + LD (.l_d+1),A + JR cloop$ +ycirc$: + LD A,(.style) + OR A + CALL NZ,.verlin + LD A,(.x_s+1) + INC A + LD (.x_s+1),A + LD B,#0 + LD A,(.x_s+1) + LD C,A + LD H,#0xFF + LD A,(.y_s+1) + CPL + LD L,A + INC HL + ADD HL,BC + LD A,(.l_d) + LD B,A + LD A,(.l_d+1) + LD C,A + ADD HL,HL + ADD HL,HL + ADD HL,BC + LD BC,#10 + ADD HL,BC + LD A,H + LD (.l_d),A + LD A,L + LD (.l_d+1),A + LD A,(.y_s+1) + DEC A + LD (.y_s+1),A + JP cloop$ + +.horlin:: + LD A,(.x_s) + LD B,A + LD A,(.y_s) + LD C,A + LD A,(.x_s+1) + LD D,A + LD A,(.y_s+1) + LD E,A + PUSH BC + PUSH DE + LD A,B + SUB E + LD H,A + LD A,B + ADD E + LD B,A + LD A,C + ADD D + LD C,A + LD D,H + LD E,C + CALL .line + POP DE + POP BC + LD A,D + OR A + RET Z + PUSH BC + PUSH DE + LD A,B + SUB E + LD H,A + LD A,B + ADD E + LD B,A + LD A,C + SUB D + LD C,A + LD D,H + LD E,C + CALL .line + POP DE + POP BC + RET + +.verlin:: + LD A,(.x_s) + LD B,A + LD A,(.y_s) + LD C,A + LD A,(.x_s+1) + LD D,A + LD A,(.y_s+1) + LD E,A + PUSH BC + PUSH DE + LD A,B + SUB E + LD H,A + LD A,B + ADD E + LD B,A + LD A,C + ADD D + LD C,A + LD D,H + LD E,C + CALL .line + POP DE + POP BC + PUSH BC + PUSH DE + LD A,B + SUB E + LD H,A + LD A,B + ADD E + LD B,A + LD A,C + SUB D + LD C,A + LD D,H + LD E,C + CALL .line + POP DE + POP BC + LD A,D + SUB E + RET Z + PUSH BC + PUSH DE + LD A,B + SUB D + LD H,A + LD A,B + ADD D + LD B,A + LD A,C + SUB E + LD C,A + LD D,H + LD E,C + CALL .line + POP DE + POP BC + PUSH BC + PUSH DE + LD A,B + SUB D + LD H,A + LD A,B + ADD D + LD B,A + LD A,C + ADD E + LD C,A + LD D,H + LD E,C + CALL .line + POP DE + POP BC + RET + +.circplot:: + LD A,(.x_s) + LD B,A + LD A,(.y_s) + LD C,A + LD A,(.x_s+1) + LD D,A + LD A,(.y_s+1) + LD E,A + PUSH BC + PUSH DE + LD A,B + ADD D + LD B,A + LD A,C + SUB E + LD C,A + CALL .plot + POP DE + POP BC + PUSH BC + PUSH DE + LD A,B + SUB E + LD B,A + LD A,C + SUB D + LD C,A + CALL .plot + POP DE + POP BC + PUSH BC + PUSH DE + LD A,B + SUB D + LD B,A + LD A,C + ADD E + LD C,A + CALL .plot + POP DE + POP BC + PUSH BC + PUSH DE + LD A,B + ADD E + LD B,A + LD A,C + ADD D + LD C,A + CALL .plot + POP DE + POP BC + + LD A,D + OR A + RET Z + SUB E + RET Z + + PUSH BC + PUSH DE + LD A,B + SUB D + LD B,A + LD A,C + SUB E + LD C,A + CALL .plot + POP DE + POP BC + PUSH BC + PUSH DE + LD A,B + SUB E + LD B,A + LD A,C + ADD D + LD C,A + CALL .plot + POP DE + POP BC + PUSH BC + PUSH DE + LD A,B + ADD D + LD B,A + LD A,C + ADD E + LD C,A + CALL .plot + POP DE + POP BC + PUSH BC + PUSH DE + LD A,B + ADD E + LD B,A + LD A,C + SUB D + LD C,A + CALL .plot + POP DE + POP BC + RET + + ;; Draw a box between (B,C) and (D,E) +.box:: + LD A,(.x_s) + LD B,A + LD A,(.x_s+1) + LD C,A + SUB B + JR NC,ychk$ + LD A,C + LD (.x_s),A + LD A,B + LD (.x_s+1),A +ychk$: + LD A,(.y_s) + LD B,A + LD A,(.y_s+1) + LD C,A + SUB B + JR NC,dbox$ + LD A,C + LD (.y_s),A + LD A,B + LD (.y_s+1),A +dbox$: + LD A,(.x_s) + LD B,A + LD D,A + LD A,(.y_s) + LD C,A + LD A,(.y_s+1) + LD E,A + CALL .line + LD A,(.x_s+1) + LD B,A + LD D,A + LD A,(.y_s) + LD C,A + LD A,(.y_s+1) + LD E,A + CALL .line + LD A,(.x_s) + INC A + LD (.x_s),A + LD A,(.x_s+1) + DEC A + LD (.x_s+1),A + LD A,(.x_s) + LD B,A + LD A,(.x_s+1) + LD D,A + LD A,(.y_s) + LD C,A + LD E,A + CALL .line + LD A,(.x_s) + LD B,A + LD A,(.x_s+1) + LD D,A + LD A,(.y_s+1) + LD C,A + LD E,A + CALL .line + LD A,(.style) + OR A + RET Z + LD A,(.x_s) + LD B,A + LD A,(.x_s+1) + SUB B + RET C + LD A,(.y_s) + INC A + LD (.y_s),A + LD A,(.y_s+1) + DEC A + LD (.y_s+1),A + LD A,(.y_s) + LD B,A + LD A,(.y_s+1) + SUB B + RET C + + .if 0 + LD A,(.mod_col) ;Swap fore + back colours. + LD D,A + AND #0xF0 + LD C,A ;Preserve Style + LD A,D + AND #0x0C + RRCA + RRCA + OR C ;Foreground->background + style + LD C,A + LD A,D + AND #0x03 + RLCA + RLCA + OR C + LD (.mod_col),A + .else + LD A,(.fg_colour) + LD C,A + LD A,(.bg_colour) + LD (.fg_colour),A + LD A,C + LD (.bg_colour),A + .endif +filllp$: + LD A,(.x_s) + LD B,A + LD A,(.x_s+1) + LD D,A + LD A,(.y_s) + LD C,A + LD E,A + CALL .line + LD A,(.y_s+1) + LD B,A + LD A,(.y_s) + CP B + JR Z,swap$ + INC A + LD (.y_s),A + JR filllp$ +swap$: + .if 0 + LD A,(.mod_col) ;Swap fore + back colours. + LD D,A + AND #0xF0 + LD C,A ;Preserve Style + LD A,D + AND #0x0C + RRCA + RRCA + OR C ;Foreground->background + style + LD C,A + LD A,D + AND #0x03 + RLCA + RLCA + OR C + LD (.mod_col),A + .else + LD A,(.fg_colour) + LD C,A + LD A,(.bg_colour) + LD (.fg_colour),A + LD A,C + LD (.bg_colour),A + .endif + RET + + ;; Draw a line between (B,C) and (D,E) +.line:: + LD A,C ;Calculate Delta Y + SUB E + JR NC,s1$ + CPL + INC A + +s1$: LD (.delta_y),A + LD H,A + + LD A,B ;Calculate Delta X + SUB D + JR NC,s2$ + CPL + INC A + +s2$: LD (.delta_x),A + + SUB H + JP C,y1 + + ;; Use Delta X + + LD A,B + SUB D + JP NC,x2$ + + LD A,C + SUB E + JR Z,x3$ + LD A,#0x00 + JR NC,x3$ + LD A,#0xFF + JR x3$ + +x2$: + LD A,E + SUB C + JR Z,x2a$ + LD A,#0x00 + JR NC,x2a$ + LD A,#0xFF + +x2a$: + LD B,D + LD C,E ;BC holds start X,Y +x3$: + LD (.l_inc),A ;Store Y increment + LD HL,#.y_table + LD D,#0x00 + LD E,C + ADD HL,DE + ADD HL,DE + LD A,(HL+) + LD H,(HL) + LD L,A + + LD A,B + AND #0xf8 + LD E,A + ADD HL,DE + ADD HL,DE + + LD A,(.delta_y) + OR A + JP Z,.xonly + + ;; Got to do it the hard way. + + ; Calculate (2*deltay) -> dinc1 + + PUSH HL + LD H,#0x00 + LD L,A + ADD HL,HL + LD A,H + LD (.dinc1),A + LD A,L + LD (.dinc1+1),A + + ; Calculate (2*deltay)-deltax -> d + + + LD D,H + LD E,L + LD A,(.delta_x) + CPL + LD L,A + LD H,#0xFF + INC HL +dx1$: + ADD HL,DE + LD A,H + LD (.l_d),A + LD A,L + LD (.l_d+1),A + + ; Calculate (deltay-deltax)*2 -> dinc2 + + LD A,(.delta_x) + CPL + LD L,A + LD H,#0xFF + INC HL + LD A,(.delta_y) + LD D,#0x00 + LD E,A + ADD HL,DE + ADD HL,HL + + LD A,H + LD (.dinc2),A + LD A,L + LD (.dinc2+1),A + + POP HL + + .if 0 + LD A,(.mod_col) + LD D,A + .endif + + LD A,(.delta_x) + LD E,A + + LD A,B + AND #7 + ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 + LD C,A + LD B,#0x00 + LD A,(BC) ; Get start bit + LD B,A + LD C,A + +xloop$: + RRC C + LD A,(.l_d) + BIT 7,A + JR Z,ychg$ + PUSH DE + BIT 7,C + JR Z,nbit$ + LD A,B + CPL + LD C,A + CALL .wrbyte + DEC HL + LD C,#0x80 + LD B,C +nbit$: + LD A,(.l_d+1) + LD D,A + LD A,(.dinc1+1) + ADD D + LD (.l_d+1),A + LD A,(.l_d) + LD D,A + LD A,(.dinc1) + ADC D + LD (.l_d),A + POP DE + JR nchg$ +ychg$: + PUSH DE + PUSH BC + LD A,B + CPL + LD C,A + CALL .wrbyte + LD A,(.l_inc) + OR A + JR Z,ydown$ + INC HL + LD A,L + AND #0x0F + JR NZ,bound$ + LD DE,#0x0130 + ADD HL,DE ;Correct screen address + JR bound$ +ydown$: + DEC HL + DEC HL + DEC HL + LD A,L + AND #0x0F + XOR #0x0E + JR NZ,bound$ + LD DE,#0xFED0 + ADD HL,DE ;Correct screen address +bound$: + LD A,(.l_d+1) + LD D,A + LD A,(.dinc2+1) + ADD D + LD (.l_d+1),A + LD A,(.l_d) + LD D,A + LD A,(.dinc2) + ADC D + LD (.l_d),A + POP BC + LD B,C + POP DE +nchg$: + BIT 7,C + JR Z,nadj$ + PUSH DE + LD DE,#0x0010 + ADD HL,DE ;Correct screen address + POP DE + LD B,C +nadj$: + LD A,B + OR C + LD B,A + DEC E + JP NZ,xloop$ + LD A,B + CPL + LD C,A + JP .wrbyte + +.xonly:: + ;; Draw accelerated horizontal line + .if 0 + ;; xxx needed? + LD A,(.mod_col) + LD D,A + .endif + + LD A,(.delta_x) + LD E,A + INC E + + LD A,B ;check X + AND #7 ;just look at bottom 3 bits + JR Z,2$ + PUSH HL + ADD #<.drawing_bits_tbl ;Table of bits is located at 0x0070 + LD L,A + LD H,#0x00 + LD C,(HL) + POP HL + XOR A ;Clear A +1$: RRCA ;Shift data right 1 + OR C + DEC E + JR Z,3$ + BIT 0,A + JR Z,1$ + JR 3$ +2$: + LD A,E + DEC A + AND #0xF8 + JR Z,4$ + JR 8$ +3$: + LD B,A + CPL + LD C,A + PUSH DE + CALL .wrbyte + LD DE,#0x0F + ADD HL,DE ;Correct screen address + POP DE + +8$: LD A,E + OR A + RET Z + AND #0xF8 + JR Z,4$ + + XOR A + LD C,A + CPL + LD B,A + + PUSH DE + CALL .wrbyte + LD DE,#0x0F + ADD HL,DE ;Correct screen address + POP DE + LD A,E + SUB #8 + RET Z + LD E,A + JR 8$ + +4$: LD A,#0x80 +5$: DEC E + JR Z,6$ + SRA A + JR 5$ +6$: LD B,A + CPL + LD C,A + JP .wrbyte + + ;; Use Delta Y +y1: + LD A,C + SUB E + JP NC,y2$ + + LD A,B + SUB D + JR Z,y3$ + LD A,#0x00 + JR NC,y3$ + LD A,#0xFF + JR y3$ + +y2$: + LD A,C + SUB E + JR Z,y2a$ + LD A,#0x00 + +; JR NC,y2a$ ; old code; fix draw to up-left below +; LD A,#0xFF + + LD L,A ; invert delta if x1 less than x2 + LD A,B + SUB D + LD A,L + JR C,y2a$ + CPL + +y2a$: + LD B,D + LD C,E ;BC holds start X,Y + +y3$: + LD (.l_inc),A ;Store X increment + LD HL,#.y_table + LD D,#0x00 + LD E,C + ADD HL,DE + ADD HL,DE + LD A,(HL+) + LD H,(HL) + LD L,A + + LD A,B + AND #0xf8 + LD E,A + ADD HL,DE + ADD HL,DE + + .if 0 + ;; Trashed by later instructions + LD A,(.mod_col) + LD D,A + .endif + + LD A,(.delta_y) + LD E,A + INC E + + LD A,(.delta_x) + OR A + JP Z,.yonly + + ;; Got to do it the hard way. + + ; Calculate (2*deltax) -> dinc1 + + PUSH HL + LD H,#0x00 + LD L,A + ADD HL,HL + LD A,H + LD (.dinc1),A + LD A,L + LD (.dinc1+1),A + + ; Calculate (2*deltax)-deltay -> d + + + LD D,H + LD E,L + LD A,(.delta_y) + CPL + LD L,A + LD H,#0xFF + INC HL +dy1$: + ADD HL,DE + LD A,H + LD (.l_d),A + LD A,L + LD (.l_d+1),A + + ; Calculate (deltax-deltay)*2 -> dinc2 + + LD A,(.delta_y) + CPL + LD L,A + LD H,#0xFF + INC HL + LD A,(.delta_x) + LD D,#0x00 + LD E,A + ADD HL,DE + ADD HL,HL + + LD A,H + LD (.dinc2),A + LD A,L + LD (.dinc2+1),A + + POP HL + + .if 0 + ;; xxx Not used? + LD A,(.mod_col) + LD D,A + .endif + + LD A,(.delta_y) + LD E,A + + LD A,B + AND #7 + ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 + LD C,A + LD B,#0x00 + LD A,(BC) ; Get start bit + LD B,A + LD C,A + +yloop$: + PUSH DE + PUSH BC + LD A,B + CPL + LD C,A + CALL .wrbyte + INC HL + LD A,L + AND #0x0F + JR NZ,nybound$ + LD DE,#0x0130 + ADD HL,DE ;Correct screen address +nybound$: + POP BC + LD A,(.l_d) + BIT 7,A + JR Z,xchg$ + LD A,(.l_d+1) + LD D,A + LD A,(.dinc1+1) + ADD D + LD (.l_d+1),A + LD A,(.l_d) + LD D,A + LD A,(.dinc1) + ADC D + LD (.l_d),A + JR nchgy$ +xchg$: + LD A,(.l_inc) + OR A + JR NZ,yright$ + RLC B + BIT 0,B + JR Z,boundy$ + LD DE,#0xFFF0 + ADD HL,DE ;Correct screen address + JR boundy$ +yright$: + RRC B + BIT 7,B + JR Z,boundy$ + LD DE,#0x0010 + ADD HL,DE ;Correct screen address +boundy$: + LD A,(.l_d+1) + LD D,A + LD A,(.dinc2+1) + ADD D + LD (.l_d+1),A + LD A,(.l_d) + LD D,A + LD A,(.dinc2) + ADC D + LD (.l_d),A +nchgy$: + POP DE + DEC E + JR NZ,yloop$ + LD A,B + CPL + LD C,A + JP .wrbyte + +.yonly:: + ;; Draw accelerated vertical line + LD A,B ;check X + AND #7 ;just look at bottom 3 bits + PUSH HL + ADD #<.drawing_bits_tbl ;Table of bits is located at 0x0070 + LD L,A + LD H,#0x00 + LD A,(HL) ;Get mask bit + POP HL + LD B,A + CPL + LD C,A + +1$: PUSH DE + CALL .wrbyte + INC HL ;Correct screen address + LD A,L + AND #0x0F + JR NZ,2$ + LD DE,#0x0130 + ADD HL,DE +2$: POP DE + DEC E + RET Z + JR 1$ + + ;; Draw a point at (B,C) with mode and color D +.plot:: + + LD HL,#.y_table + LD D,#0x00 + LD E,C + ADD HL,DE + ADD HL,DE + LD A,(HL+) + LD H,(HL) + LD L,A + + LD A,B + AND #0xf8 + LD E,A + ADD HL,DE + ADD HL,DE + + LD A,B + + AND #7 + ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 + LD C,A + LD B,#0x00 + LD A,(BC) + LD B,A + CPL + LD C,A + +.wrbyte:: + .if 0 + LD A,(.mod_col) ; Restore color and mode + LD D,A + + BIT 5,D + JR NZ,10$ + BIT 6,D + JR NZ,20$ + BIT 7,D + JR NZ,30$ + .else + LD A,(.fg_colour) + LD D,A + LD A,(.draw_mode) + CP #.M_OR + JR Z,10$ + CP #.M_XOR + JR Z,20$ + CP #.M_AND + JR Z,30$ + .endif + + ; Fall through to SOLID by default +1$: + ;; Solid + LD E,B + .if 0 + BIT 2,D + .else + BIT 0,D + .endif + JR NZ,2$ + PUSH BC + LD B,#0x00 +2$: + .if 0 + BIT 3,D + .else + BIT 1,D + .endif + JR NZ,3$ + LD E,#0x00 +3$: + WAIT_STAT + + LD A,(HL) + AND C + OR B + LD (HL+),A + + LD A,(HL) + AND C + OR E + LD (HL),A + LD A,B + OR A + RET NZ + POP BC + RET + +10$: + ;; Or + LD C,B + .if 0 + BIT 2,D + .else + BIT 0,D + .endif + JR NZ,11$ + LD B,#0x00 +11$: + .if 0 + BIT 3,D + .else + BIT 1,D + .endif + JR NZ,12$ + LD C,#0x00 +12$: + WAIT_STAT + + LD A,(HL) + OR B + LD (HL+),A + + LD A,(HL) + OR C + LD (HL),A + RET + +20$: + ;; Xor + LD C,B + .if 0 + BIT 2,D + .else + BIT 0,D + .endif + JR NZ,21$ + LD B,#0x00 +21$: + .if 0 + BIT 3,D + .else + BIT 1,D + .endif + JR NZ,22$ + LD C,#0x00 +22$: + WAIT_STAT + + LD A,(HL) + XOR B + LD (HL+),A + + LD A,(HL) + XOR C + LD (HL),A + RET + +30$: + ;; And + LD B,C + .if 0 + BIT 2,D + .else + BIT 0,D + .endif + JR Z,31$ + LD B,#0xFF +31$: + .if 0 + BIT 3,D + .else + BIT 1,D + .endif + JR Z,32$ + LD C,#0xFF +32$: + WAIT_STAT + + LD A,(HL) + AND B + LD (HL+),A + + LD A,(HL) + AND C + LD (HL),A + RET + + ;; Get color of pixel at point (B,C) returns in A +.getpix:: + LD HL,#.y_table + LD D,#0x00 + LD E,C + ADD HL,DE + ADD HL,DE + LD A,(HL+) + LD H,(HL) + LD L,A + + LD A,B + AND #0xf8 + LD E,A + ADD HL,DE + ADD HL,DE + + LD A,B + + AND #7 + ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 + LD C,A + LD B,#0x00 + LD A,(BC) + LD C,A + + WAIT_STAT + + LD A,(HL+) + LD D,A + LD A,(HL+) + LD E,A + LD B,#0 + LD A,D + AND C + JR Z,1$ + SET 0,B +1$: LD A,E + AND C + JR Z,2$ + SET 1,B +2$: LD E,B + RET + + ;; Write character C +.wrtchr:: + LD HL,#.y_table + LD D,#0x00 + LD A,(.ty) + RLCA + RLCA + RLCA + LD E,A + ADD HL,DE + ADD HL,DE + LD A,(HL+) + LD B, A + LD H,(HL) + LD L,B + + LD A,(.tx) + RLCA + RLCA + RLCA + LD E,A + ADD HL,DE + ADD HL,DE + + LD A,C + LD B,H + LD C,L + + LD H,D + LD L,A + ADD HL,HL + ADD HL,HL + ADD HL,HL + + .if 0 + LD DE,#.tp1 + .else + .globl _font_ibm_fixed_tiles + + LD DE,#_font_ibm_fixed_tiles + .endif + + ADD HL,DE + + LD D,H + LD E,L + LD H,B + LD L,C + + .if 0 + LD A,(.mod_col) + LD C,A + .else + LD A,(.fg_colour) + LD C,A + .endif +1$: + LD A,(DE) + INC DE + PUSH DE + + .if 1 + PUSH HL + LD HL,#.bg_colour + LD L,(HL) + .endif + + LD B,A + XOR A + .if 0 + BIT 0,C + .else + BIT 0,L + .endif + JR Z,2$ + CPL +2$: OR B + .if 0 + BIT 2,C + .else + BIT 0,C + .endif + JR NZ,3$ + XOR B +3$: LD D,A + XOR A + .if 0 + BIT 1,C + .else + BIT 1,L + .endif + JR Z,4$ + CPL +4$: OR B + .if 0 + BIT 3,C + .else + BIT 1,C + .endif + JR NZ,5$ + XOR B +5$: + LD E,A + .if 1 + POP HL + .endif + + WAIT_STAT + + LD A,D + LD (HL+),A + LD A,E + LD (HL+),A + POP DE + LD A,L + AND #0x0F + JR NZ,1$ + RET + + .area _CODE +_gotogxy:: + LDA HL,2(SP) ; Skip return address + LD A,(HL+) ; A = x + LD (.tx),A + LD A,(HL+) ; A = y + LD (.ty),A + + RET + +_wrtchr:: + PUSH BC + + LD A,(.mode) + CP #.G_MODE + CALL NZ,.gmode + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL) + LD C,A ; C = Char to print + + CALL .wrtchr + CALL .adv_gcurs + + POP BC + RET + +_getpix:: + PUSH BC + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; B = x + LD B,A + LD A,(HL+) ; C = y + LD C,A + + CALL .getpix + + POP BC + RET + +_circle:: + PUSH BC + + LD A,(.mode) + CP #.G_MODE + CALL NZ,.gmode + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; B = x + LD B,A + LD A,(HL+) ; C = y + LD C,A + LD A,(HL+) ; D = Radius + LD D,A + LD A,(HL) + LD (.style),A + + CALL .circle + + POP BC + RET + +_box:: + PUSH BC + + LD A,(.mode) + CP #.G_MODE + CALL NZ,.gmode + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; B = x1 + LD (.x_s),A + LD A,(HL+) ; C = y1 + LD (.y_s),A + LD A,(HL+) ; D = x2 + LD (.x_s+1),A + LD A,(HL+) ; E = y2 + LD (.y_s+1),A + LD A,(HL) + LD (.style),A + CALL .box + POP BC + RET + +_line:: + PUSH BC + + LD A,(.mode) + CP #.G_MODE + CALL NZ,.gmode + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; B = x1 + LD B,A + LD A,(HL+) ; C = y1 + LD C,A + LD A,(HL+) ; D = x2 + LD D,A + LD A,(HL+) ; E = y2 + LD E,A + + CALL .line + + POP BC + RET + +_plot_point:: + PUSH BC + + LD A,(.mode) + CP #.G_MODE + CALL NZ,.gmode + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; B = x + LD B,A + LD A,(HL+) ; C = y + LD C,A + + CALL .plot + + POP BC + RET + + ;; Old, compatible version of plot() +_plot:: + PUSH BC + + LD A,(.mode) + CP #.G_MODE + CALL NZ,.gmode + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; B = x + LD B,A + LD A,(HL+) ; C = y + LD C,A + LD A,(HL+) ; colour + LD (.fg_colour),A + LD A,(HL+) ; mode + LD (.draw_mode),A + + CALL .plot + + POP BC + RET + + .area _BASE +_switch_data:: ; Non Banked as pointer + PUSH BC + + LD A,(.mode) + CP #.G_MODE + CALL NZ,.gmode + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; B = x + LD B,A + LD A,(HL+) ; C = y + LD C,A + LD A,(HL+) ; DE = src + LD E,A + LD A,(HL+) + LD D,A + LD A,(HL+) ; HL = dst + LD H,(HL) + LD L,A + + CALL .switch_data + + POP BC + RET + + +_draw_image:: ; Non banked as pointer + PUSH BC + + LD A,(.mode) + CP #.G_MODE + CALL NZ,.gmode + + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) ; HL = data + LD C,A + LD B,(HL) + + CALL .draw_image + + POP BC + RET + + .area _BASE +.y_table:: + .word 0x8100,0x8102,0x8104,0x8106,0x8108,0x810A,0x810C,0x810E + .word 0x8240,0x8242,0x8244,0x8246,0x8248,0x824A,0x824C,0x824E + .word 0x8380,0x8382,0x8384,0x8386,0x8388,0x838A,0x838C,0x838E + .word 0x84C0,0x84C2,0x84C4,0x84C6,0x84C8,0x84CA,0x84CC,0x84CE + .word 0x8600,0x8602,0x8604,0x8606,0x8608,0x860A,0x860C,0x860E + .word 0x8740,0x8742,0x8744,0x8746,0x8748,0x874A,0x874C,0x874E + .word 0x8880,0x8882,0x8884,0x8886,0x8888,0x888A,0x888C,0x888E + .word 0x89C0,0x89C2,0x89C4,0x89C6,0x89C8,0x89CA,0x89CC,0x89CE + .word 0x8B00,0x8B02,0x8B04,0x8B06,0x8B08,0x8B0A,0x8B0C,0x8B0E + .word 0x8C40,0x8C42,0x8C44,0x8C46,0x8C48,0x8C4A,0x8C4C,0x8C4E + .word 0x8D80,0x8D82,0x8D84,0x8D86,0x8D88,0x8D8A,0x8D8C,0x8D8E + .word 0x8EC0,0x8EC2,0x8EC4,0x8EC6,0x8EC8,0x8ECA,0x8ECC,0x8ECE + .word 0x9000,0x9002,0x9004,0x9006,0x9008,0x900A,0x900C,0x900E + .word 0x9140,0x9142,0x9144,0x9146,0x9148,0x914A,0x914C,0x914E + .word 0x9280,0x9282,0x9284,0x9286,0x9288,0x928A,0x928C,0x928E + .word 0x93C0,0x93C2,0x93C4,0x93C6,0x93C8,0x93CA,0x93CC,0x93CE + .word 0x9500,0x9502,0x9504,0x9506,0x9508,0x950A,0x950C,0x950E + .word 0x9640,0x9642,0x9644,0x9646,0x9648,0x964A,0x964C,0x964E diff --git a/gbdk-lib/libc/targets/gbz80/drawing_isr.s b/gbdk-lib/libc/targets/gbz80/drawing_isr.s @@ -0,0 +1,23 @@ + .include "global.s" + + .area _BASE + +.drawing_vbl:: + LDH A,(.LCDC) + OR #LCDCF_BG8000 ; Set BG Chr to 0x8000 + LDH (.LCDC),A + + LD A,#72 ; Set line at which LCD interrupt occurs + LDH (.LYC),A + + RET + + ;; Is the STAT check required, as we are already in the HBL? +.drawing_lcd:: + WAIT_STAT + + LDH A,(.LCDC) + AND #~LCDCF_BG8000 ; Set BG Chr to 0x8800 + LDH (.LCDC),A + + RET diff --git a/gbdk-lib/libc/gb/f_ibm_full.s b/gbdk-lib/libc/targets/gbz80/f_ibm_full.s diff --git a/gbdk-lib/libc/gb/f_ibm_sh.s b/gbdk-lib/libc/targets/gbz80/f_ibm_sh.s diff --git a/gbdk-lib/libc/gb/f_italic.s b/gbdk-lib/libc/targets/gbz80/f_italic.s diff --git a/gbdk-lib/libc/gb/f_min.s b/gbdk-lib/libc/targets/gbz80/f_min.s diff --git a/gbdk-lib/libc/gb/f_spect.s b/gbdk-lib/libc/targets/gbz80/f_spect.s diff --git a/gbdk-lib/libc/gb/far_ptr.s b/gbdk-lib/libc/targets/gbz80/far_ptr.s diff --git a/gbdk-lib/libc/gb/fill_rect.s b/gbdk-lib/libc/targets/gbz80/fill_rect.s diff --git a/gbdk-lib/libc/gb/fill_rect_bk.s b/gbdk-lib/libc/targets/gbz80/fill_rect_bk.s diff --git a/gbdk-lib/libc/gb/fill_rect_wi.s b/gbdk-lib/libc/targets/gbz80/fill_rect_wi.s diff --git a/gbdk-lib/libc/targets/gbz80/font.s b/gbdk-lib/libc/targets/gbz80/font.s @@ -0,0 +1,705 @@ +; font.ms +; +; Michael Hope, 1999 +; michaelh@earthling.net +; Distrubuted under the Artistic License - see www.opensource.org +; + .include "global.s" + + .globl .cr_curs + .globl .adv_curs + .globl .cury, .curx + .globl .display_off + + ; Structure offsets + sfont_handle_sizeof = 3 + sfont_handle_font = 1 + sfont_handle_first_tile = 0 + + ; Encoding types - lower 2 bits of font + FONT_256ENCODING = 0 + FONT_128ENCODING = 1 + FONT_NOENCODING = 2 + + ; Other bits + FONT_BCOMPRESSED = 2 + + .CR = 0x0A ; Unix + .SPACE = 0x00 + + ; Maximum number of fonts + .MAX_FONTS = 6 + + .area _FONT_HEADER (ABS) + + .org .MODE_TABLE+4*.T_MODE + JP .tmode + + .module font.ms + + ; Globals from drawing.s + ; FIXME: Hmmm... check the linkage of these + .globl .fg_colour + .globl .bg_colour + + .area _BSS + ; The current font +.start_font_vars: + +font_current:: + .ds sfont_handle_sizeof + ; Cached copy of the first free tile +font_first_free_tile:: + .ds 1 + ; Table containing descriptors for all of the fonts +font_table:: + .ds sfont_handle_sizeof*.MAX_FONTS +.end_font_vars: + + .area _GSINIT + + xor a + ld (#.curx),a + ld (#.cury),a + ld hl,#.start_font_vars + ld c,#(.end_font_vars - .start_font_vars) + rst 0x28 + + .area _BASE + +_font_load_ibm:: + ld hl,#_font_ibm + call font_load + ret + + ; Copy uncompressed 16 byte tiles from (BC) to (HL), length = DE*2 + ; Note: HL must be aligned on a uint16_t boundry +font_copy_uncompressed:: + ld a,d + or e + ret z + + ld a,h + cp #0x98 + jr c,4$ + sub #0x98-0x88 + ld h,a +4$: + xor a + cp e ; Special for when e=0 you will get another loop + jr nz,1$ + dec d +1$: + WAIT_STAT + ld a,(bc) + ld (hl+),a + inc bc + + WAIT_STAT + ld a,(bc) + ld (hl),a + inc bc + + inc l + jr nz,2$ + inc h + ld a,h ; Special wrap-around + cp #0x98 + jr nz,2$ + ld h,#0x88 +2$: + dec e + jr nz,1$ + dec d + bit 7,d ; -1? + jr z,1$ + ret + + ; Copy a set of compressed (8 bytes/cell) tiles to VRAM + ; Sets the foreground and background colours based on the current + ; font colours + ; Entry: + ; From (BC) to (HL), length (DE) where DE = #cells * 8 + ; Uses the current fg_colour and bg_colour fields +font_copy_compressed:: + ld a,d + or e + ret z ; Do nothing + + ld a,h + cp #0x98 ; Take care of the 97FF -> 8800 wrap around + jr c,font_copy_compressed_loop + sub #0x98-0x88 + ld h,a +font_copy_compressed_loop: + push de + ld a,(bc) + ld e,a + inc bc + push bc + + ld bc,#0 + ; Do the background colour first + ld a,(.bg_colour) + bit 0,a + jr z,font_copy_compressed_bg_grey1 + ld b,#0xFF +font_copy_compressed_bg_grey1: + bit 1,a + jr z,font_copy_compressed_bg_grey2 + ld c,#0xFF +font_copy_compressed_bg_grey2: + ; BC contains the background colour + ; Compute what xoring we need to do to get the correct fg colour + ld d,a + ld a,(.fg_colour) + xor d + ld d,a + + bit 0,d + jr z,font_copy_compressed_grey1 + ld a,e + xor b + ld b,a +font_copy_compressed_grey1: + bit 1,d + jr z,font_copy_compressed_grey2 + ld a,e + xor c + ld c,a +font_copy_compressed_grey2: + WAIT_STAT + + ld (hl),b + inc l ; can't overflow here + ld (hl),c + inc hl + + ld a,h ; Take care of the 97FFF -> 8800 wrap around + cp #0x98 + jr nz,1$ + ld h,#0x88 +1$: + pop bc + pop de + dec de + ld a,d + or e + jr nz,font_copy_compressed_loop + ret + +; Load the font HL +font_load:: + call .display_off + push hl + + ; Find the first free font entry + ld hl,#font_table+sfont_handle_font + ld b,#.MAX_FONTS +font_load_find_slot: + ld a,(hl) ; Check to see if this entry is free + inc hl ; Free is 0000 for the font pointer + or (hl) + cp #0 + jr z,font_load_found + + inc hl + inc hl + dec b + jr nz,font_load_find_slot + pop hl + ld hl,#0 + jr font_load_exit ; Couldn't find a free space +font_load_found: + ; HL points to the end of the free font table entry + pop de + ld (hl),d ; Copy across the font struct pointer + dec hl + ld (hl),e + + ld a,(font_first_free_tile) + dec hl + ld (hl),a + + push hl + call font_set ; Set this new font to be the default + + ; Only copy the tiles in if were in text mode + ld a,(.mode) + and #.T_MODE + + call nz,font_copy_current + + ; Increase the 'first free tile' counter + ld hl,#font_current+sfont_handle_font + ld a,(hl+) + ld h,(hl) + ld l,a + + inc hl ; Number of tiles used + ld a,(font_first_free_tile) + add a,(hl) + ld (font_first_free_tile),a + + pop hl ; Return font setup in HL +font_load_exit: + ;; Turn the screen on + LDH A,(.LCDC) + OR #(LCDCF_ON | LCDCF_BGON) + AND #~(LCDCF_BG9C00 | LCDCF_BG8000) + LDH (.LCDC),A + + RET + + ; Copy the tiles from the current font into VRAM +font_copy_current:: + ; Find the current font data + ld hl,#font_current+sfont_handle_font + ld a,(hl+) + ld h,(hl) + ld l,a + + inc hl ; Points to the 'tiles required' entry + ld a,(hl-) + ld d,#0 + rla ; Multiple DE by 8 + rl d + rla + rl d + rla + rl d + ld e, a ; DE has the length of the tile data + + ld a,(hl) ; Get the flags + push af + and #3 ; Only lower 2 bits set encoding table size + + ld bc,#128 + cp #FONT_128ENCODING ; 0 for 256 char encoding table, 1 for 128 char + jr z,font_copy_current_copy + + ld bc,#0 + cp #FONT_NOENCODING + jr z,font_copy_current_copy + + ld bc,#256 ; Must be 256 element encoding +font_copy_current_copy: + inc hl + inc hl ; Points to the start of the encoding table + add hl,bc + ld c,l + ld b,h ; BC points to the start of the tile data + + ; Find the offset in VRAM for this font + ld a,(font_current+sfont_handle_first_tile) ; First tile used for this font + swap a + ld l,a + and #0x0f + ld h,a + ld a, l + and #0xf0 + ld l, a + + ld a,#0x90 ; Tile 0 is at 9000h + add a,h + ld h,a + ; Is this font compressed? + pop af ; Recover flags + bit FONT_BCOMPRESSED,a + ; Do the jump in a mildly different way + jp z,font_copy_uncompressed + jp font_copy_compressed + + ; Set the current font to HL +font_set:: + ld a,(hl+) + ld (font_current),a + ld a,(hl+) + ld (font_current+1),a + ld a,(hl+) + ld (font_current+2),a + ret + + ;; Print a character with interpretation +.put_char:: + ; See if it's a special char + cp #.CR + jr nz,1$ + + ; Now see if were checking special chars + push af + ld a,(.mode) + and #.M_NO_INTERP + jr nz,2$ + call .cr_curs + pop af + ret +2$: + pop af +1$: + call .set_char + jp .adv_curs + + ;; Print a character without interpretation +.out_char:: + call .set_char + jp .adv_curs + + ;; Delete a character +.del_char:: + call .rew_curs + ld a,#.SPACE + jp .set_char + + ;; Print the character in A +.set_char: + push af + ld a,(font_current+2) + ; Must be non-zero if the font system is setup (cant have a font in page zero) + or a + jr nz,3$ + + ; Font system is not yet setup - init it and copy in the ibm font + ; Kind of a compatibility mode + call _font_init + + ; Need all of the tiles + xor a + ld (font_first_free_tile),a + + call _font_load_ibm +3$: + pop af + push bc + push de + push hl + ; Compute which tile maps to this character + ld e,a + ld hl,#font_current+sfont_handle_font + ld a,(hl+) + ld h,(hl) + ld l,a + ld a,(hl+) + and #3 + cp #FONT_NOENCODING + jr z,set_char_no_encoding + inc hl + ; Now at the base of the encoding table + ; E is set above + ld d,#0 + add hl,de + ld e,(hl) ; That's the tile! +set_char_no_encoding: + ld a,(font_current+0) + add a,e + ld e,a + + LD A,(.cury) ; Y coordinate + LD L,A + LD H,#0x00 + ADD HL,HL + ADD HL,HL + ADD HL,HL + ADD HL,HL + ADD HL,HL + LD A,(.curx) ; X coordinate + LD C,A + LD B,#0x00 + ADD HL,BC + LD BC,#0x9800 + ADD HL,BC + + WAIT_STAT + + LD (HL),E + POP HL + POP DE + POP BC + RET + + .area _CODE +_putchar:: + PUSH BC + LDA HL,4(SP) ; Skip return address + LD A,(HL) ; A = c + CALL .put_char + POP BC + RET + +_setchar:: + PUSH BC + LDA HL,4(SP) ; Skip return address + LD A,(HL) ; A = c + CALL .set_char + POP BC + RET + + .area _BASE +_font_load:: + push bc + LDA HL,4(SP) ; Skip return address and bc + LD A,(HL) ; A = c + inc hl + ld h,(hl) + ld l,a + call font_load + push hl + pop de ; Return in DE + pop bc + ret + +_font_set:: + push bc + LDA HL,4(SP) ; Skip return address + LD A,(HL) ; A = c + inc hl + ld h,(hl) + ld l,a + call font_set + pop bc + ld de,#0 ; Always good... + ret + +_font_init:: + push bc + .globl .tmode + + call .tmode + + xor a + ld (font_first_free_tile),a + + ; Clear the font table + ld hl,#font_table + ld b,#sfont_handle_sizeof*.MAX_FONTS +1$: + ld (hl+),a + dec b + jr nz,1$ + ld a,#3 + ld (.fg_colour),a + ld a,#0 + ld (.bg_colour),a + + call .cls + pop bc + ret + +_cls:: +.cls:: + PUSH DE + PUSH HL + LD HL,#0x9800 + LD E,#0x20 ; E = height +1$: + LD D,#0x20 ; D = width +2$: + WAIT_STAT + + LD (HL),#.SPACE ; Always clear + INC HL + DEC D + JR NZ,2$ + DEC E + JR NZ,1$ + POP HL + POP DE + RET + + .area _CODE + ; Support routines +_gotoxy:: + lda hl,2(sp) + ld a,(hl+) + ld (.curx),a + ld a,(hl) + ld (.cury),a + ret + +_posx:: + LD A,(.mode) + AND #.T_MODE + JR NZ,1$ + PUSH BC + CALL .tmode + POP BC +1$: + LD A,(.curx) + LD E,A + RET + +_posy:: + LD A,(.mode) + AND #.T_MODE + JR NZ,1$ + PUSH BC + CALL .tmode + POP BC +1$: + LD A,(.cury) + LD E,A + RET + + .area _BASE + ;; Rewind the cursor +.rew_curs: + PUSH HL + LD HL,#.curx ; X coordinate + XOR A + CP (HL) + JR Z,1$ + DEC (HL) + JR 99$ +1$: + LD (HL),#.MAXCURSPOSX + LD HL,#.cury ; Y coordinate + XOR A + CP (HL) + JR Z,99$ + DEC (HL) +99$: + POP HL + RET + +.cr_curs:: + PUSH HL + XOR A + LD (.curx),A + LD HL,#.cury ; Y coordinate + LD A,#.MAXCURSPOSY + CP (HL) + JR Z,2$ + INC (HL) + JR 99$ +2$: + CALL .scroll +99$: + POP HL + RET + +.adv_curs:: + PUSH HL + LD HL,#.curx ; X coordinate + LD A,#.MAXCURSPOSX + CP (HL) + JR Z,1$ + INC (HL) + JR 99$ +1$: + LD (HL),#0x00 + LD HL,#.cury ; Y coordinate + LD A,#.MAXCURSPOSY + CP (HL) + JR Z,2$ + INC (HL) + JR 99$ +2$: + ;; See if scrolling is disabled + LD A,(.mode) + AND #.M_NO_SCROLL + JR Z,3$ + ;; Nope - reset the cursor to (0,0) + XOR A + LD (.cury),A + LD (.curx),A + JR 99$ +3$: + CALL .scroll +99$: + POP HL + RET + + ;; Scroll the whole screen +.scroll: + PUSH BC + PUSH DE + PUSH HL + LD HL,#0x9800 + LD BC,#0x9800+0x20 ; BC = next line + LD E,#0x20-0x01 ; E = height - 1 +1$: + LD D,#0x20 ; D = width +2$: + WAIT_STAT + LD A,(BC) + LD (HL+),A + INC BC + + DEC D + JR NZ,2$ + DEC E + JR NZ,1$ + + LD D,#0x20 +3$: + WAIT_STAT + LD A,#.SPACE + LD (HL+),A + DEC D + JR NZ,3$ + + POP HL + POP DE + POP BC + RET + + .area _BSS +.curx:: ; Cursor position + .ds 0x01 +.cury:: + .ds 0x01 + + .area _BASE + + .globl .drawing_vbl + .globl .drawing_lcd + .globl .int_0x40 + .globl .int_0x48 + .globl .remove_int + + ;; Enter text mode +.tmode:: + DI ; Disable interrupts + + ;; Turn the screen off + LDH A,(.LCDC) + AND #LCDCF_ON + JR Z,1$ + + ;; Turn the screen off + CALL .display_off + + ;; Remove any interrupts setup by the drawing routine + LD BC,#.drawing_vbl + LD HL,#.int_0x40 + CALL .remove_int + LD BC,#.drawing_lcd + LD HL,#.int_0x48 + CALL .remove_int +1$: + + CALL .tmode_out + + ;; Turn the screen on + LDH A,(.LCDC) + OR #(LCDCF_ON | LCDCF_BGON) + AND #~(LCDCF_BG9C00 | LCDCF_BG8000) + LDH (.LCDC),A + + EI ; Enable interrupts + + RET + + ;; Text mode (out only) +.tmode_out:: + XOR A + LD (.curx),A + LD (.cury),A + + ;; Clear screen + CALL .cls + + LD A,#.T_MODE + LD (.mode),A + + RET diff --git a/gbdk-lib/libc/targets/gbz80/gb/Makefile b/gbdk-lib/libc/targets/gbz80/gb/Makefile @@ -0,0 +1,52 @@ +# GB specific Makefile + +TOPDIR = ../../../.. + +THIS = gb +PORT = gbz80 + +CSRC = digits.c gprint.c gprintf.c gprintln.c gprintn.c + +ASSRC = cgb.s cgb_palettes.s cgb_compat.s \ + cpy_data.s \ + drawing.s drawing_isr.s color.s \ + f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \ + get_bk_t.s get_data.s get_tile.s \ + get_wi_t.s get_xy_t.s \ + get_addr.s \ + hiramcpy.s init_tt.s input.s \ + pad.s sample.s \ + serial.s set_bk_t.s set_tile.s \ + set_data.s set_prop.s set_spr.s set_wi_t.s set_xy_t.s \ + set_1bit_data.s \ + sgb.s font.s delay.s \ + bgb_emu.s bgb_emu_printf.s \ + nowait.s far_ptr.s \ + lcd.s joy.s tim.s \ + crash_handler.s \ + ___sdcc_bcall_ehl.s ___sdcc_bcall.s \ + mv_spr.s \ + pad_ex.s \ + mode.s clock.s \ + get_t.s set_t.s init_vram.s \ + fill_rect.s fill_rect_bk.s fill_rect_wi.s \ + metasprites.s metasprites_flip.s metasprites_hide.s metasprites_hide_spr.s \ + set_tile_submap.s set_win_tile_submap.s \ + gb_decompress.s gb_decompress_tiles.s \ + heap.s \ + crt0.s + +ifeq ($(ASM),asxxxx) +ASSRC += sfr.s +endif +ifeq ($(ASM),rgbds) +ASSRC += stubs.s +endif + +CRT0 = crt0.s + +include $(TOPDIR)/Makefile.common + +AS = $(AS_GBZ80) + +include ../../../Makefile.platform diff --git a/gbdk-lib/libc/targets/gbz80/gb/crt0.s b/gbdk-lib/libc/targets/gbz80/gb/crt0.s @@ -0,0 +1,508 @@ + .include "global.s" + + ;; **************************************** + ;; Beginning of module + ;; BANKED: checked + .title "Runtime" + .module Runtime + .area _HEADER (ABS) + + ;; RST vectors +; .org 0x00 ; Trap, utilized by crash_handler.h + +; .org 0x08 ; --profile handler utilized by bgb_emu.h + +; .org 0x10 ; empty + +; .org 0x18 ; empty + + .org 0x20 ; RST 0x20 == call HL +.call_hl:: + JP (HL) + + .org 0x28 ; zero up to 256 bytes in C pointed by HL +.MemsetSmall:: + LD (HL+),A + DEC C + JR NZ,.MemsetSmall + ret + + .org 0x30 ; copy up to 256 bytes in C from DE to HL +.MemcpySmall:: + LD A, (DE) + LD (HL+), A + INC DE + DEC C + JR NZ,.MemcpySmall + RET + +; .org 0x38 ; crash handler utilized by crash_handler.h + + ;; Hardware interrupt vectors + .org 0x40 ; VBL +.int_VBL: + PUSH AF + PUSH HL + LD HL,#.int_0x40 + JP .int + +; .org 0x48 ; LCD + +; .org 0x50 ; TIM + +; .org 0x58 ; SIO + +; .org 0x60 ; JOY + +; .org 0x70 + ;; space for drawing.s bit table + + .org 0x80 +.int:: + PUSH BC + PUSH DE +1$: + LD A,(HL+) + OR (HL) + JR Z,.int_tail + PUSH HL + LD A,(HL-) + LD L,(HL) + LD H,A + RST 0x20 ; .call_hl + POP HL + INC HL + JR 1$ +_wait_int_handler:: + ADD SP,#4 +.int_tail: + POP DE + POP BC + POP HL + + ;; we return at least at the beginning of mode 2 + WAIT_STAT + + POP AF + RETI + + ;; VBlank default interrupt routine +__standard_VBL_handler:: +.std_vbl: + LD HL,#.sys_time + INC (HL) + JR NZ,2$ + INC HL + INC (HL) +2$: + CALL .refresh_OAM + + LD A, #1 + LDH (.vbl_done),A + RET + + ;; GameBoy Header + + ;; DO NOT CHANGE... + .org 0x100 +.header: + JR .code_start + + ;; Nintendo logo + .org 0x104 + .byte 0xCE,0xED,0x66,0x66 + .byte 0xCC,0x0D,0x00,0x0B + .byte 0x03,0x73,0x00,0x83 + .byte 0x00,0x0C,0x00,0x0D + .byte 0x00,0x08,0x11,0x1F + .byte 0x88,0x89,0x00,0x0E + .byte 0xDC,0xCC,0x6E,0xE6 + .byte 0xDD,0xDD,0xD9,0x99 + .byte 0xBB,0xBB,0x67,0x63 + .byte 0x6E,0x0E,0xEC,0xCC + .byte 0xDD,0xDC,0x99,0x9F + .byte 0xBB,0xB9,0x33,0x3E + + ;; Title of the game + .org 0x134 + .asciz "Title" + + .org 0x144 + .byte 0,0,0 + + ;; Cartridge type is ROM only + .org 0x147 + .byte 0 + + ;; ROM size is 32kB + .org 0x148 + .byte 0 + + ;; RAM size is 0kB + .org 0x149 + .byte 0 + + ;; Maker ID + .org 0x14A + .byte 0x00,0x00 + + ;; Version number + .org 0x14C + .byte 0x01 + + ;; Complement check + .org 0x14D + .byte 0x00 + + ;; Checksum + .org 0x14E + .byte 0x00,0x00 + + ;; **************************************** + .org 0x150 + + ;; soft reset: falldown to .code_start +.reset:: +_reset:: + LD A, (__is_GBA) + LD B, A + LD A, (__cpu) + + ;; Initialization code +.code_start:: + DI ; Disable interrupts + LD D, A ; Store CPU type in D + LD E, B ; Store GBA flag in E + ;; Initialize the stack + LD SP, #.STACK + + LD A, #>_shadow_OAM + LDH (__shadow_OAM_base), A + LD H, A + XOR A + LD L, A + LD C, #(40 << 2) ; 40 entries 4 bytes each + RST 0x28 + + ;; Clear CRT0 global variables + LD HL,#.start_crt_globals + LD C,#(.end_crt_globals - .start_crt_globals) + RST 0x28 + +; LD (.mode),A ; Clearing (.mode) is performed when clearing RAM + + ;; Store CPU type + LD A, D + LD (__cpu), A + CP #.CGB_TYPE + JR NZ, 1$ + XOR A + SRL E + RLA + LD (__is_GBA), A +1$: + ;; Turn the screen off + CALL .display_off + + XOR A + ;; Initialize the display + LDH (.SCY),A + LDH (.SCX),A + LDH (.STAT),A + LDH (.WY),A + LD A,#0x07 + LDH (.WX),A + + ;; Copy refresh_OAM routine to HRAM + LD DE,#.start_refresh_OAM ; source + LD HL,#.refresh_OAM ; dest + LD C,#(.end_refresh_OAM - .start_refresh_OAM) ; size + RST 0x30 ; call .MemcpySmall + + ;; Clear the OAM by calling refresh_OAM + CALL .refresh_OAM + + ;; Install interrupt routines + LD BC,#.std_vbl + CALL .add_VBL + + ;; Standard color palettes + LD A,#0b11100100 ; Grey 3 = 11 (Black) + ; Grey 2 = 10 (Dark grey) + ; Grey 1 = 01 (Light grey) + ; Grey 0 = 00 (Transparent) + LDH (.BGP),A + LDH (.OBP0),A + LD A,#0b00011011 + LDH (.OBP1),A + + ;; Turn the screen on + LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGOFF) + LDH (.LCDC),A + XOR A + LDH (.IF),A + LD A,#.VBL_IFLAG ; switch on VBlank interrupt only + LDH (.IE),A + + LDH (__current_bank),A ; current bank is 1 at startup + + XOR A + + LD HL,#.sys_time + LD (HL+),A + LD (HL),A + + LDH (.NR52),A ; Turn sound off + + CALL gsinit + + EI ; Enable interrupts + + ;; Call the main function + CALL _main +_exit:: +99$: + HALT + NOP + JR 99$ ; Wait forever + +_set_interrupts:: + DI + LDA HL,2(SP) ; Skip return address + XOR A + LDH (.IF),A ; Clear pending interrupts + LD A,(HL) + EI ; Enable interrupts + LDH (.IE),A ; interrupts are still disabled here + RET + + ;; Copy OAM data to OAM RAM +.start_refresh_OAM: + LDH A,(__shadow_OAM_base) + OR A + RET Z + + LDH (.DMA),A ; Put A into DMA registers + LD A,#0x28 ; We need to wait 160 ns +1$: + DEC A + JR NZ,1$ + RET +.end_refresh_OAM: + + .org .MODE_TABLE + ;; Jump table for modes + RET + + ;; **************************************** + + ;; Ordering of segments for the linker + ;; Code that really needs to be in bank 0 + .area _HOME + ;; Similar to _HOME + .area _BASE + ;; Code + .area _CODE + ;; #pragma bank 0 workaround + .area _CODE_0 + ;; Constant data + .area _LIT +; ;; since _CODE_1 area base address is pre-defined in the linker from 0x4000, +; ;; that moves initializer code and tables out of bank 0 +; .area _CODE_1 + ;; Constant data, used to init _DATA + .area _INITIALIZER + ;; Code, used to init _DATA + .area _GSINIT + .area _GSFINAL + ;; Uninitialised ram data + .area _DATA + .area _BSS + ;; Initialised in ram data + .area _INITIALIZED + ;; For malloc + .area _HEAP + + .area _BSS +.start_crt_globals: + +__cpu:: + .ds 0x01 ; GB type (GB, PGB, CGB) +__is_GBA:: + .ds 0x01 ; detect GBA +.mode:: + .ds 0x01 ; Current mode +.sys_time:: +_sys_time:: + .ds 0x02 ; System time in VBL units +.int_0x40:: + .blkw 0x0A ; 4 interrupt handlers (built-in + user-defined) + +.end_crt_globals: + + .area _HRAM (ABS) + + .org 0xFF90 +__current_bank:: ; Current bank + .ds 0x01 +.vbl_done: + .ds 0x01 ; Is VBL interrupt finished? +__shadow_OAM_base:: + .ds 0x01 + + ;; Runtime library + .area _GSINIT +gsinit:: + LD DE, #l__INITIALIZER + LD A, D + OR E + JR Z, 4$ + LD HL, #s__INITIALIZED + LD BC, #s__INITIALIZER + + SRL D + RR E + JR NC,3$ + LD A,(BC) + LD (HL+),A + INC BC +3$: + INC D + INC E + JR 2$ +1$: + LD A,(BC) + LD (HL+),A + INC BC + LD A,(BC) + LD (HL+),A + INC BC +2$: + DEC E + JR NZ,1$ + DEC D + JR NZ,1$ +4$: + + .area _GSFINAL + ret + + .area _HOME + + ;; Remove interrupt routine in BC from the VBL interrupt list + ;; falldown to .remove_int +.remove_VBL:: + LD HL,#.int_0x40 + + ;; Remove interrupt BC from interrupt list HL if it exists + ;; Abort if a 0000 is found (end of list) +.remove_int:: +1$: + LD A,(HL+) + LD E,A + LD D,(HL) + INC HL + OR D + RET Z ; No interrupt found + + LD A,E + CP C + JR NZ,1$ + LD A,D + CP B + JR NZ,1$ + + LD D,H + LD E,L + DEC DE + DEC DE + + ;; Now do a memcpy from here until the end of the list +2$: + LD A,(HL+) + LD (DE),A + LD B,A + INC DE + LD A,(HL+) + LD (DE),A + INC DE + OR B + RET Z + JR 2$ + + ;; Add interrupt routine in BC to the VBL interrupt list + ;; falldown to .add_int +.add_VBL:: + LD HL,#.int_0x40 + + ;; Add interrupt routine in BC to the interrupt list in HL +.add_int:: +1$: + LD A,(HL+) + OR (HL) + JR Z,2$ + INC HL + JR 1$ +2$: + LD A,B + LD (HL-),A + LD (HL),C + RET + + ;; Wait for VBL interrupt to be finished +.wait_vbl_done:: +_wait_vbl_done:: + ;; Check if the screen is on + LDH A,(.LCDC) + AND #LCDCF_ON + RET Z ; Return if screen is off + XOR A + LDH (.vbl_done),A ; Clear any previous sets of vbl_done +1$: + HALT ; Wait for any interrupt + NOP ; HALT sometimes skips the next instruction + LDH A,(.vbl_done) ; Was it a VBlank interrupt? + ;; Warning: we may lose a VBlank interrupt, if it occurs now + OR A + JR Z,1$ ; No: back to sleep! + RET + +.display_off:: +_display_off:: + ;; Check if the screen is on + LDH A,(.LCDC) + AND #LCDCF_ON + RET Z ; Return if screen is off +1$: ; We wait for the *NEXT* VBL + LDH A,(.LY) + CP #0x92 ; Smaller than or equal to 0x91? + JR NC,1$ ; Loop until smaller than or equal to 0x91 +2$: + LDH A,(.LY) + CP #0x91 ; Bigger than 0x90? + JR C,2$ ; Loop until bigger than 0x90 + + LDH A,(.LCDC) + AND #~LCDCF_ON + LDH (.LCDC),A ; Turn off screen + RET + +_remove_VBL:: + PUSH BC + LDA HL,4(SP) ; Skip return address and registers + LD A,(HL+) + LD C,A + LD B,(HL) + CALL .remove_VBL + POP BC + RET + +_add_VBL:: + PUSH BC + LDA HL, 4(SP) ; Skip return address and registers + LD A,(HL+) + LD C,A + LD B,(HL) + CALL .add_VBL + POP BC + RET diff --git a/gbdk-lib/libc/targets/gbz80/gb/global.s b/gbdk-lib/libc/targets/gbz80/gb/global.s @@ -0,0 +1,508 @@ + .NEAR_CALLS = 1 ; <near_calls> - tag so that sed can change this + + ;; Changed by astorgb.pl to 1 + __RGBDS__ = 0 + + _VRAM = 0x8000 ; $8000->$9FFF + _VRAM8000 = 0x8000 + _VRAM8800 = 0x8800 + _VRAM9000 = 0x9000 + _SCRN0 = 0x9800 ; $9800->$9BFF + _SCRN1 = 0x9C00 ; $9C00->$9FFF + _SRAM = 0xA000 ; $A000->$BFFF + _RAM = 0xC000 ; $C000->$CFFF / $C000->$DFFF + _RAMBANK = 0xD000 ; $D000->$DFFF + _OAMRAM = 0xFE00 ; $FE00->$FE9F + _IO = 0xFF00 ; $FF00->$FF7F,$FFFF + _AUD3WAVERAM = 0xFF30 ; $FF30->$FF3F + _HRAM = 0xFF80 ; $FF80->$FFFE + + ;; MBC Equates + + .MBC1_ROM_PAGE = 0x2000 ; Address to write to for MBC1 switching + + rRAMG = 0x0000 ; $0000->$1fff + rROMB0 = 0x2000 ; $2000->$2fff + rROMB1 = 0x3000 ; $3000->$3fff - If more than 256 ROM banks are present. + rRAMB = 0x4000 ; $4000->$5fff - Bit 3 enables rumble (if present) + + ;; Keypad + .START = 0x80 + .SELECT = 0x40 + .B = 0x20 + .A = 0x10 + .DOWN = 0x08 + .UP = 0x04 + .LEFT = 0x02 + .RIGHT = 0x01 + + .P14 = 0x10 + .P15 = 0x20 + + ;; Screen dimensions + .MAXCURSPOSX = 0x13 ; In tiles + .MAXCURSPOSY = 0x11 + + .SCREENWIDTH = 0xA0 + .SCREENHEIGHT = 0x90 + .MINWNDPOSX = 0x07 + .MINWNDPOSY = 0x00 + .MAXWNDPOSX = 0xA6 + .MAXWNDPOSY = 0x8F + + ;; Hardware registers + + .P1 = 0x00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10 + rP1 = 0xFF00 + + P1F_5 = 0b00100000 ; P15 out port, set to 0 to get buttons + P1F_4 = 0b00010000 ; P14 out port, set to 0 to get dpad + P1F_3 = 0b00001000 ; P13 in port + P1F_2 = 0b00000100 ; P12 in port + P1F_1 = 0b00000010 ; P11 in port + P1F_0 = 0b00000001 ; P10 in port + + P1F_GET_DPAD = 0b00100000 + P1F_GET_BTN = 0b00010000 + P1F_GET_NONE = 0b00110000 + + .SB = 0x01 ; Serial IO data buffer + rSB = 0xFF01 + + .SC = 0x02 ; Serial IO control register + rSC = 0xFF02 + + .DIV = 0x04 ; Divider register + rDIV = 0xFF04 + + .TIMA = 0x05 ; Timer counter + rTIMA = 0xFF05 + + .TMA = 0x06 ; Timer modulo + rTMA = 0xFF06 + + .TAC = 0x07 ; Timer control + rTAC = 0xFF07 + + TACF_START = 0b00000100 + TACF_STOP = 0b00000000 + TACF_4KHZ = 0b00000000 + TACF_16KHZ = 0b00000011 + TACF_65KHZ = 0b00000010 + TACF_262KHZ = 0b00000001 + + .IF = 0x0F ; Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL + rIF = 0xFF0F + + .NR10 = 0x10 ; Sound register + rNR10 = 0xFF10 + rAUD1SWEEP = 0xFF10 + + AUD1SWEEP_UP = 0b00000000 + AUD1SWEEP_DOWN = 0b00001000 + + .NR11 = 0x11 ; Sound register + rNR11 = 0xFF11 + rAUD1LEN = 0xFF11 + + .NR12 = 0x12 ; Sound register + rNR12 = 0xFF12 + rAUD1ENV = 0xFF12 + + .NR13 = 0x13 ; Sound register + rNR13 = 0xFF13 + rAUD1LOW = 0xFF13 + + .NR14 = 0x14 ; Sound register + rNR14 = 0xFF14 + rAUD1HIGH = 0xFF14 + + .NR21 = 0x16 ; Sound register + rNR21 = 0xFF16 + rAUD2LEN = 0xFF16 + + .NR22 = 0x17 ; Sound register + rNR22 = 0xFF17 + rAUD2ENV = 0xFF17 + + .NR23 = 0x18 ; Sound register + rNR23 = 0xFF18 + rAUD2LOW = 0xFF18 + + .NR24 = 0x19 ; Sound register + rNR24 = 0xFF19 + rAUD2HIGH = 0xFF19 + + .NR30 = 0x1A ; Sound register + rNR30 = 0xFF1A + rAUD3ENA = 0xFF1A + + .NR31 = 0x1B ; Sound register + rNR31 = 0xFF1B + rAUD3LEN = 0xFF1B + + .NR32 = 0x1C ; Sound register + rNR32 = 0xFF1C + rAUD3LEVEL = 0xFF1C + + .NR33 = 0x1D ; Sound register + rNR33 = 0xFF1D + rAUD3LOW = 0xFF1D + + .NR34 = 0x1E ; Sound register + rNR34 = 0xFF1E + rAUD3HIGH = 0xFF1E + + .NR41 = 0x20 ; Sound register + rNR41 = 0xFF20 + rAUD4LEN = 0xFF20 + + .NR42 = 0x21 ; Sound register + rNR42 = 0xFF21 + rAUD4ENV = 0xFF21 + + .NR43 = 0x22 ; Sound register + rNR43 = 0xFF22 + rAUD4POLY = 0xFF22 + + .NR44 = 0x23 ; Sound register + rNR44 = 0xFF23 + rAUD4GO = 0xFF23 + + .NR50 = 0x24 ; Sound register + rNR50 = 0xFF24 + rAUDVOL = 0xFF24 + + AUDVOL_VIN_LEFT = 0b10000000 ; SO2 + AUDVOL_VIN_RIGHT = 0b00001000 ; SO1 + + .NR51 = 0x25 ; Sound register + rNR51 = 0xFF25 + rAUDTERM = 0xFF25 + + AUDTERM_4_LEFT = 0b10000000 + AUDTERM_3_LEFT = 0b01000000 + AUDTERM_2_LEFT = 0b00100000 + AUDTERM_1_LEFT = 0b00010000 + AUDTERM_4_RIGHT = 0b00001000 + AUDTERM_3_RIGHT = 0b00000100 + AUDTERM_2_RIGHT = 0b00000010 + AUDTERM_1_RIGHT = 0b00000001 + + .NR52 = 0x26 ; Sound register + rNR52 = 0xFF26 + rAUDENA = 0xFF26 + + AUDENA_ON = 0b10000000 + AUDENA_OFF = 0b00000000 ; sets all audio regs to 0! + + .LCDC = 0x40 ; LCD control + rLCDC = 0xFF40 + + LCDCF_OFF = 0b00000000 ; LCD Control Operation + LCDCF_ON = 0b10000000 ; LCD Control Operation + LCDCF_WIN9800 = 0b00000000 ; Window Tile Map Display Select + LCDCF_WIN9C00 = 0b01000000 ; Window Tile Map Display Select + LCDCF_WINOFF = 0b00000000 ; Window Display + LCDCF_WINON = 0b00100000 ; Window Display + LCDCF_BG8800 = 0b00000000 ; BG & Window Tile Data Select + LCDCF_BG8000 = 0b00010000 ; BG & Window Tile Data Select + LCDCF_BG9800 = 0b00000000 ; BG Tile Map Display Select + LCDCF_BG9C00 = 0b00001000 ; BG Tile Map Display Select + LCDCF_OBJ8 = 0b00000000 ; OBJ Construction + LCDCF_OBJ16 = 0b00000100 ; OBJ Construction + LCDCF_OBJOFF = 0b00000000 ; OBJ Display + LCDCF_OBJON = 0b00000010 ; OBJ Display + LCDCF_BGOFF = 0b00000000 ; BG Display + LCDCF_BGON = 0b00000001 ; BG Display + LCDCF_B_ON = 7 + LCDCF_B_WIN9C00 = 6 + LCDCF_B_WINON = 5 + LCDCF_B_BG8000 = 4 + LCDCF_B_BG9C00 = 3 + LCDCF_B_OBJ16 = 2 + LCDCF_B_OBJON = 1 + LCDCF_B_BGON = 0 + + .STAT = 0x41 ; LCD status + rSTAT = 0xFF41 + + STATF_LYC = 0b01000000 ; LYC=LY Coincidence (Selectable) + STATF_MODE10 = 0b00100000 ; Mode 10 + STATF_MODE01 = 0b00010000 ; Mode 01 (V-Blank) + STATF_MODE00 = 0b00001000 ; Mode 00 (H-Blank) + STATF_LYCF = 0b00000100 ; Coincidence Flag + STATF_HBL = 0b00000000 ; H-Blank + STATF_VBL = 0b00000001 ; V-Blank + STATF_OAM = 0b00000010 ; OAM-RAM is used by system + STATF_LCD = 0b00000011 ; Both OAM and VRAM used by system + STATF_BUSY = 0b00000010 ; When set, VRAM access is unsafe + STATF_B_LYC = 6 + STATF_B_MODE10 = 5 + STATF_B_MODE01 = 4 + STATF_B_MODE00 = 3 + STATF_B_LYCF = 2 + STATF_B_VBL = 0 + STATF_B_OAM = 1 + STATF_B_BUSY = 1 + + .SCY = 0x42 ; Scroll Y + rSCY = 0xFF42 + + .SCX = 0x43 ; Scroll X + rSCX = 0xFF43 + + .LY = 0x44 ; LCDC Y-coordinate + rLY = 0xFF44 + + .LYC = 0x45 ; LY compare + rLYC = 0xFF45 + + .DMA = 0x46 ; DMA transfer + rDMA = 0xFF46 + + .BGP = 0x47 ; BG palette data + rBGP = 0xFF47 + + .OBP0 = 0x48 ; OBJ palette 0 data + rOBP0 = 0xFF48 + + .OBP1 = 0x49 ; OBJ palette 1 data + rOBP1 = 0xFF49 + + .WY = 0x4A ; Window Y coordinate + rWY = 0xFF4A + + .WX = 0x4B ; Window X coordinate + rWX = 0xFF4B + + .KEY1 = 0x4D ; CPU speed + rKEY1 = 0xFF4D + rSPD = 0xFF4D + + KEY1F_DBLSPEED = 0b10000000 ; 0=Normal Speed, 1=Double Speed (R) + KEY1F_PREPARE = 0b00000001 ; 0=No, 1=Prepare (R/W) + + .VBK = 0x4F ; VRAM bank + rVBK = 0xFF4F + + .HDMA1 = 0x51 ; DMA control 1 + rHDMA1 = 0xFF51 + + .HDMA2 = 0x52 ; DMA control 2 + rHDMA2 = 0xFF52 + + .HDMA3 = 0x53 ; DMA control 3 + rHDMA3 = 0xFF53 + + .HDMA4 = 0x54 ; DMA control 4 + rHDMA4 = 0xFF54 + + .HDMA5 = 0x55 ; DMA control 5 + rHDMA5 = 0xFF55 + + HDMA5F_MODE_GP = 0b00000000 ; General Purpose DMA (W) + HDMA5F_MODE_HBL = 0b10000000 ; HBlank DMA (W) + + HDMA5F_BUSY = 0b10000000 ; 0=Busy (DMA still in progress), 1=Transfer complete (R) + + .RP = 0x56 ; IR port + rRP = 0xFF56 + + RPF_ENREAD = 0b11000000 + RPF_DATAIN = 0b00000010 ; 0=Receiving IR Signal, 1=Normal + RPF_WRITE_HI = 0b00000001 + RPF_WRITE_LO = 0b00000000 + + .BCPS = 0x68 ; BG color palette specification + rBCPS = 0xFF68 + + BCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing) + + .BCPD = 0x69 ; BG color palette data + rBCPD = 0xFF69 + + .OCPS = 0x6A ; OBJ color palette specification + rOCPS = 0xFF6A + + OCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing) + + .OCPD = 0x6B ; OBJ color palette data + rOCPD = 0xFF6B + + .SVBK = 0x70 ; WRAM bank + rSVBK = 0xFF70 + rSMBK = 0xFF70 + + rPCM12 = 0xFF76 + + rPCM34 = 0xFF77 + + .IE = 0xFF ; Interrupt enable + rIE = 0xFFFF + + .VBL_IFLAG = 0x01 + .LCD_IFLAG = 0x02 + .TIM_IFLAG = 0x04 + .SIO_IFLAG = 0x08 + .JOY_IFLAG = 0x10 + + IEF_HILO = 0b00010000 ; Transition from High to Low of Pin number P10-P13 + IEF_SERIAL = 0b00001000 ; Serial I/O transfer end + IEF_TIMER = 0b00000100 ; Timer Overflow + IEF_STAT = 0b00000010 ; STAT + IEF_VBLANK = 0b00000001 ; V-Blank + + ;; Flags common to multiple sound channels + + AUDLEN_DUTY_12_5 = 0b00000000 ; 12.5% + AUDLEN_DUTY_25 = 0b01000000 ; 25% + AUDLEN_DUTY_50 = 0b10000000 ; 50% + AUDLEN_DUTY_75 = 0b11000000 ; 75% + + AUDENV_UP = 0b00001000 + AUDENV_DOWN = 0b00000000 + + AUDHIGH_RESTART = 0b10000000 + AUDHIGH_LENGTH_ON = 0b01000000 + AUDHIGH_LENGTH_OFF = 0b00000000 + + ;; OAM related constants + + OAM_COUNT = 40 ; number of OAM entries in OAM RAM + + OAMF_PRI = 0b10000000 ; Priority + OAMF_YFLIP = 0b01000000 ; Y flip + OAMF_XFLIP = 0b00100000 ; X flip + OAMF_PAL0 = 0b00000000 ; Palette number; 0,1 (DMG) + OAMF_PAL1 = 0b00010000 ; Palette number; 0,1 (DMG) + OAMF_BANK0 = 0b00000000 ; Bank number; 0,1 (GBC) + OAMF_BANK1 = 0b00001000 ; Bank number; 0,1 (GBC) + + OAMF_PALMASK = 0b00000111 ; Palette (GBC) + + OAMB_PRI = 7 ; Priority + OAMB_YFLIP = 6 ; Y flip + OAMB_XFLIP = 5 ; X flip + OAMB_PAL1 = 4 ; Palette number; 0,1 (DMG) + OAMB_BANK1 = 3 ; Bank number; 0,1 (GBC) + + ;; CPU detection + .DMG_TYPE = 0x01 ; Original GB or Super GB + .MGB_TYPE = 0xFF ; Pocket GB or Super GB 2 + .CGB_TYPE = 0x11 ; Color GB + + ;; GBDK library screen modes + + .G_MODE = 0x01 ; Graphic mode + .T_MODE = 0x02 ; Text mode (bit 2) + .T_MODE_OUT = 0x02 ; Text mode output only + .T_MODE_INOUT = 0x03 ; Text mode with input + .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode + .M_NO_INTERP = 0x08 ; Disables special character interpretation + + ;; Status codes for IO + .IO_IDLE = 0x00 + .IO_SENDING = 0x01 + .IO_RECEIVING = 0x02 + .IO_ERROR = 0x04 + + ;; Type of IO data + .DT_IDLE = 0x66 + .DT_RECEIVING = 0x55 + + ;; Table of routines for modes + .MODE_TABLE = 0x01E0 + + ;; C related + ;; Overheap of a banked call. Used for parameters + ;; = ret + real ret + bank + + .if .NEAR_CALLS + .BANKOV = 2 + + .else + .BANKOV = 6 + + .endif + + .globl __current_bank + .globl __shadow_OAM_base + + ;; Global variables + .globl .mode + + .globl __cpu + .globl __is_GBA + + ;; Global routines +; .globl .set_mode ;; don't link mode.o by default + + .globl .reset + + .globl .display_off + + .globl .wait_vbl_done + + ;; Interrupt routines + .globl .add_VBL +; .globl .add_LCD ;; don't link LCD.o by default +; .globl .add_TIM ;; don't link TIM.o by default +; .globl .add_SIO ;; don't link serial.o by default +; .globl .add_JOY ;; don't link JOY.o by default + + ;; Symbols defined at link time + .globl .STACK + .globl _shadow_OAM + .globl .refresh_OAM + + ;; Main user routine + .globl _main + + ;; Macro definitions + +.macro WAIT_STAT ?lbl +lbl: LDH A, (.STAT) + AND #STATF_BUSY ; Check if in LCD modes 0 or 1 + JR NZ, lbl +.endm + +.macro ADD_A_REG16 regH regL + ADD regL + LD regL, A + ADC regH + SUB regL + LD regH, A +.endm + +.macro SIGNED_ADD_A_REG16 regH regL ?lbl + ; If A is negative, we need to subtract 1 from upper byte of 16-bit value + BIT 7, A ; set z if a signed bit is 0 + JR Z, lbl ; if z is set jump to positive + dec regH ; if negative decrement upper byte +lbl: + ADD_A_REG16 regH, regL +.endm + +.macro SIGNED_SUB_A_REG16 regH regL ?lbl + ; negate A then add to 16-bit value + CPL + INC A + SIGNED_ADD_A_REG16 regH, regL +.endm + +.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2 ?lbl3 + ; Multiply DE by A, return result in HL; preserves: BC + LD HL, #0 +lbl1: + SRL A + JR NC, lbl2 + ADD HL, DE +lbl2: + JR Z, lbl3 + SLA E + RL D + JR lbl1 +lbl3: +.endm + diff --git a/gbdk-lib/libc/gb/sfr.s b/gbdk-lib/libc/targets/gbz80/gb/sfr.s diff --git a/gbdk-lib/libc/gb/gb_decompress.s b/gbdk-lib/libc/targets/gbz80/gb_decompress.s diff --git a/gbdk-lib/libc/gb/gb_decompress_tiles.s b/gbdk-lib/libc/targets/gbz80/gb_decompress_tiles.s diff --git a/gbdk-lib/libc/gb/get_addr.s b/gbdk-lib/libc/targets/gbz80/get_addr.s diff --git a/gbdk-lib/libc/gb/get_bk_t.s b/gbdk-lib/libc/targets/gbz80/get_bk_t.s diff --git a/gbdk-lib/libc/gb/get_data.s b/gbdk-lib/libc/targets/gbz80/get_data.s diff --git a/gbdk-lib/libc/gb/get_t.s b/gbdk-lib/libc/targets/gbz80/get_t.s diff --git a/gbdk-lib/libc/gb/get_tile.s b/gbdk-lib/libc/targets/gbz80/get_tile.s diff --git a/gbdk-lib/libc/gb/get_wi_t.s b/gbdk-lib/libc/targets/gbz80/get_wi_t.s diff --git a/gbdk-lib/libc/gb/get_xy_t.s b/gbdk-lib/libc/targets/gbz80/get_xy_t.s diff --git a/gbdk-lib/libc/gb/gprint.c b/gbdk-lib/libc/targets/gbz80/gprint.c diff --git a/gbdk-lib/libc/gb/gprintf.c b/gbdk-lib/libc/targets/gbz80/gprintf.c diff --git a/gbdk-lib/libc/gb/gprintln.c b/gbdk-lib/libc/targets/gbz80/gprintln.c diff --git a/gbdk-lib/libc/gb/gprintn.c b/gbdk-lib/libc/targets/gbz80/gprintn.c diff --git a/gbdk-lib/libc/gb/heap.s b/gbdk-lib/libc/targets/gbz80/heap.s diff --git a/gbdk-lib/libc/gb/hiramcpy.s b/gbdk-lib/libc/targets/gbz80/hiramcpy.s diff --git a/gbdk-lib/libc/gb/init_tt.s b/gbdk-lib/libc/targets/gbz80/init_tt.s diff --git a/gbdk-lib/libc/gb/init_vram.s b/gbdk-lib/libc/targets/gbz80/init_vram.s diff --git a/gbdk-lib/libc/targets/gbz80/input.s b/gbdk-lib/libc/targets/gbz80/input.s @@ -0,0 +1,647 @@ + .include "global.s" + + ;; Note that while gets uses a pointer, the pointer had better + ;; be in non-banked RAM else bad things will happen. + ;; BANKED: checked, imperfect + + .globl .copy_vram + .globl .set_xy_wtt + .globl .mv_sprite + .globl .set_sprite_prop + .globl .set_sprite_tile + .globl .jpad + .globl .padup + + .MINMSPOSX = 0x02 ; In tiles + .MINMSPOSY = 0x0A + .MAXMSPOSX = 0x11 + .MAXMSPOSY = 0x0F + .INIMSPOSX = .MINMSPOSX + .INIMSPOSY = .MINMSPOSY + + .KBDWINPOSY = 0x08 ; In tiles + .KBDSIZE = 0x1006 + + .MSOFFSETX = 0x0C ; In pixels + .MSOFFSETY = 0x14 + + .MINACCEL = 0x0800 + .MAXACCEL = 0x0100 + + .CR = 0x0A ; Unix +; .CR = 0x0D ; Dos + + .globl .tmode_out ; From 'output.s' + .globl .put_char + .globl .del_char + .globl .cury + + .area _INPUT_HEADER (ABS) + + .org .MODE_TABLE+4*.T_MODE_INOUT + JP .tmode_inout + + .module Terminal + + .area _BSS + +.msx: ; Mouse position + .ds 0x01 +.msy: + .ds 0x01 +.msacc: ; Mouse acceleration + .ds 0x02 +.msstate: ; Mouse state + .ds 0x01 +.mschanged: ; Did the mouse move? + .ds 0x01 +.string_len: ; Used length of input buffer + .ds 0x01 + + .area _BASE + + ;; Enter text mode with input +.tmode_inout:: + DI ; Disable interrupts + + ;; Turn the screen off + LDH A,(.LCDC) + AND #LCDCF_ON + JR Z,1$ + + ;; Turn the screen off + CALL .display_off +1$: + + LD A,(.mode) + AND #.T_MODE + CALL Z,.tmode_out + + LD BC,#.tp1 ; Move pointer + LD HL,#0x8000 + LD DE,#.endtp1-.tp1 + CALL .copy_vram + + LD A,#<.MINACCEL ; Acceleration + LD (.msacc),A + LD A,#>.MINACCEL + LD (.msacc+1),A + + ;; Initialize window + LD BC,#.frame_tiles + LD DE,#0x140A ; 0x140A + LD HL,#0 + CALL set_recoded_win_tiles + + LD BC,#.kbdtable + LD DE,#.KBDSIZE + LD HL,#(0x20 * 2 + 2) ; X=2, Y=2 + CALL set_recoded_win_tiles + + LD A,#.MINWNDPOSX + LDH (.WX),A + LD A,#.MAXWNDPOSY ; Hide window + LDH (.WY),A + + XOR A + ;; Initialize sprite + LD C,A ; Sprite 0x00 + LD D,A ; Default sprite properties + CALL .set_sprite_prop + XOR A + LD C,A ; Sprite 0x00 + LD D,A ; Tile 0x00 + CALL .set_sprite_tile + LD A,#0b00101100 + LDH (.OBP0),A + + ;; Turn the screen on + LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGON) + LDH (.LCDC),A + + LD A,#.T_MODE_INOUT + LD (.mode),A + + EI ; Enable interrupts + + RET + +set_recoded_win_tiles:: + LDH A,(.LCDC) + AND #LCDCF_WIN9C00 + JR Z,2$ + LD A,#0x9C + JR 3$ +2$: + LD A,#0x98 +3$: + ADD H + LD H,A + PUSH DE + PUSH HL +4$: + LD A,(BC) + INC BC + PUSH BC + PUSH HL + + LD C,A + LD HL,#(font_current+1) ; font_current+sfont_handle_font + LD A,(HL+) + LD H,(HL) + LD L,A + LD A,(HL+) + AND #3 + CP #2 ; FONT_NOENCODING + JR Z,5$ + INC HL + LD B,#0 + ADD HL,BC + LD C,(HL) +5$: + POP HL + + WAIT_STAT + LD A,C + LD (HL+),A + + POP BC + + DEC D + JR NZ,4$ + + POP HL + POP DE + + LD A,L + ADD #0x20 + LD L,A + ADC H + SUB L + LD H,A + DEC E + + PUSH DE + PUSH HL + JR NZ,4$ + + ADD SP,#4 + RET + + .area _CODE + ;; Prompt the user for a char and return it in A +.get_char: + PUSH BC + PUSH DE + PUSH HL + CALL .show_kbd + CALL .show_mouse +1$: + CALL .track_mouse + CALL .update_mouse + CALL .jpad + LD D,A + AND #.A ; Is A pressed ? + JP Z,1$ + + LD A,(.msy) ; Look for char under the mouse + SUB #.MINMSPOSY + JR Z,12$ + LD E,A + XOR A +11$: + ADD #.MAXMSPOSX-.MINMSPOSX+1 + DEC E + JR NZ,11$ +12$: + LD E,A + LD A,(.msx) + SUB #.MINMSPOSX + ADD E + LD HL,#.kbdtable + LD B,#0x00 + LD C,A + ADD HL,BC + LD B,(HL) + + CALL .hide_mouse + CALL .hide_kbd + LD A,B + + POP HL + POP DE + POP BC + RET + + ;; Prompt the user for a string and store it in (HL) +.get_string: + PUSH BC + PUSH DE + PUSH HL + CALL .show_kbd + CALL .show_bkg + CALL .show_mouse + XOR A + LD (.string_len),A +1$: + CALL .track_mouse + CALL .update_mouse + CALL .jpad + LD D,A + AND #.A ; Is A pressed ? + JP NZ,10$ + LD A,D + AND #.B ; Is B pressed ? + JP NZ,20$ + LD A,D + AND #.SELECT ; Is SELECT pressed ? + JP NZ,30$ + LD A,D + AND #.START ; Is START pressed ? + JR Z,1$ + CALL .padup ; Wait for button to be depressed + + LD A,#.CR + CALL .put_char + LD (HL),#0x00 + CALL .hide_mouse + CALL .hide_bkg + CALL .hide_kbd + POP HL + POP DE + POP BC + RET + +10$: + ;; Insert a character at cursor position + LD A,(.string_len) ; Check buffer length +; CP #.BUFLEN-1 ; Keep 1 char for EOS +; JR Z,13$ + INC A + LD (.string_len),A ; Update it + LD A,(.msy) ; Look for char under the mouse + SUB #.MINMSPOSY + JR Z,12$ + LD E,A + XOR A +11$: + ADD #.MAXMSPOSX-.MINMSPOSX+1 + DEC E + JR NZ,11$ +12$: + LD E,A + LD A,(.msx) + SUB #.MINMSPOSX + ADD E + PUSH HL + LD HL,#.kbdtable + LD B,#0x00 + LD C,A + ADD HL,BC + LD A,(HL) + POP HL + LD (HL+),A ; Add it into input buffer + CALL .put_char ; Print it + CALL .show_bkg ; Ensure the text is not hidden +13$: + CALL .padup ; Wait for button to be depressed + JP 1$ + +20$: + ;; Delete a character at cursor position + LD A,(.string_len) ; Is there any char in the buffer ? + OR A + JR Z,21$ + DEC A ; Yes + LD (.string_len),A ; Update buffer length + DEC HL + CALL .del_char +21$: + CALL .padup ; Wait for button to be depressed + JP 1$ + +30$: + CALL .hide_mouse + CALL .hide_bkg + CALL .hide_kbd + CALL .padup ; Wait for button to be depressed + CALL .show_kbd + CALL .show_bkg + CALL .show_mouse + JP 1$ + +.show_kbd: + PUSH BC + PUSH DE + LDH A,(.LCDC) + OR #LCDCF_WINON ; Window = On + LDH (.LCDC),A + LD A,#.MAXWNDPOSY ; Show window +1$: + BIT 0,A ; Wait for VBL every 2 pixels (slow down) + JR NZ,2$ + LD B,A + CALL .wait_vbl_done + LD A,B +2$: + LDH (.WY),A + CP #.KBDWINPOSY*0x08 + JR Z,99$ + DEC A + JR 1$ +99$: + POP DE + POP BC + RET + +.hide_kbd: + PUSH BC + PUSH DE + LD A,#.KBDWINPOSY*0x08+1 +1$: ; Hide window + BIT 0,A ; Wait for VBL every 2 pixels (slow down) + JR Z,2$ + LD B,A + CALL .wait_vbl_done + LD A,B +2$: + LDH (.WY),A + CP #.MAXWNDPOSY + JR Z,3$ + INC A + JR 1$ +3$: + LDH A,(.LCDC) + AND #~LCDCF_WINON ; Window = Off + LDH (.LCDC),A + POP DE + POP BC + RET + +.show_bkg: + PUSH BC + PUSH DE + LDH A,(.SCY) + LD D,A + LD A,(.cury) + SUB #.KBDWINPOSY-1 + JR C,99$ + JR Z,99$ + SLA A ; A = A * 8 + SLA A + SLA A + SUB D + JR C,99$ + JR Z,99$ + LD C,A + LDH A,(.SCY) +1$: + BIT 0,A ; Wait for VBL every 2 pixels (slow down) + JR Z,2$ + LD B,A + CALL .wait_vbl_done + LD A,B +2$: + INC A + LDH (.SCY),A + DEC C + JR Z,99$ + JR 1$ +99$: + POP DE + POP BC + RET + +.hide_bkg: + LDH A,(.SCY) + OR A + RET Z + PUSH BC + PUSH DE +1$: + BIT 0,A ; Wait for VBL every 2 pixels (slow down) + JR Z,2$ + LD B,A + CALL .wait_vbl_done + LD A,B +2$: + DEC A + LDH (.SCY),A + JR Z,99$ + JR 1$ +99$: + POP DE + POP BC + RET + +.show_mouse: + LD A,#.INIMSPOSX + LD (.msx),A + LD A,#.INIMSPOSY + LD (.msy),A + CALL .set_mouse + LDH A,(.LCDC) + OR #LCDCF_OBJON ; OBJ = On + LDH (.LCDC),A + RET + +.hide_mouse: + LDH A,(.LCDC) + AND #~LCDCF_OBJON ; OBJ = Off + LDH (.LCDC),A + RET + +.track_mouse: + PUSH BC + PUSH DE + PUSH HL + XOR A + LD (.mschanged),A ; Default to no change + CALL .jpad + LD D,A + + LD HL,#.msstate + AND #.UP+.DOWN+.LEFT+.RIGHT + JR NZ,1$ + LD (HL),#0x00 ; Reset state + JP 99$ +1$: + LD A,(HL) + LD (HL),#0x01 ; Set state + OR A ; Was it 0 ? + LD HL,#.msacc ; Acceleration + JR NZ,2$ + ; Yes + LD (HL),#<.MINACCEL + INC HL + LD (HL),#>.MINACCEL + JR 4$ ; Update position +2$: + LD A,(HL+) + LD C, A + LD B,(HL) + DEC BC + LD A,B + OR C + JR Z,3$ + LD (HL),B + DEC HL + LD (HL),C + JP 99$ +3$: ; Set new acceleration to maximum + LD (HL),#>.MAXACCEL + DEC HL + LD (HL),#<.MAXACCEL +4$: ; Update position + LD A,#0x01 + LD (.mschanged),A + LD A,D + AND #.UP ; Is UP pressed ? + JR Z,6$ + LD A,(.msy) + CP #.MINMSPOSY + JR Z,5$ + DEC A + LD (.msy),A + JR 6$ +5$: + LD A,#.MAXMSPOSY + LD (.msy),A +6$: + LD A,D + AND #.DOWN ; Is DOWN pressed ? + JR Z,8$ + LD A,(.msy) + CP #.MAXMSPOSY + JR Z,7$ + INC A + LD (.msy),A + JR 8$ +7$: + LD A,#.MINMSPOSY + LD (.msy),A +8$: + LD A,D + AND #.LEFT ; Is LEFT pressed ? + JR Z,10$ + LD A,(.msx) + CP #.MINMSPOSX + JR Z,9$ + DEC A + LD (.msx),A + JR 10$ +9$: + LD A,#.MAXMSPOSX + LD (.msx),A +10$: + LD A,D + AND #.RIGHT ; Is RIGHT pressed ? + JR Z,99$ + LD A,(.msx) + CP #.MAXMSPOSX + JR Z,11$ + INC A + LD (.msx),A + JR 99$ +11$: + LD A,#.MINMSPOSX + LD (.msx),A +99$: + POP HL + POP DE + POP BC + RET + +.update_mouse: + LD A,(.mschanged) ; Did it change ? + OR A + RET Z ; No +.set_mouse: + PUSH BC + PUSH DE + PUSH HL + LD C,#0x00 ; Sprite 0x00 + LD A,(.msx) + SLA A ; A = A * 8 + SLA A + SLA A + ADD #.MSOFFSETX + LD D,A + LD A,(.msy) + SLA A ; A = A * 8 + SLA A + SLA A + ADD #.MSOFFSETY + LD E,A + CALL .mv_sprite + POP HL + POP DE + POP BC + RET + +_getchar:: + LD A,(.mode) + CP #.T_MODE_INOUT + JR Z,1$ + PUSH BC + CALL .tmode_inout + POP BC +1$: + CALL .get_char + LD E,A + RET + +_gets:: + LD A,(.mode) + CP #.T_MODE_INOUT + JR Z,1$ + PUSH BC + CALL .tmode_inout + POP BC +1$: + LDA HL,2(SP) ; Skip return address + LD A,(HL+) + LD H,(HL) ; HL = s + LD L,A + PUSH HL + CALL .get_string + POP DE + RET + + ;; PENDING: this is unfortunate. Refed from .tmode_inout + .area _BASE +.tp1: + +.pointers: + + ; Tile 0x00 + .byte 0xFF,0xFF,0xFE,0x82,0xFC,0x84,0xFC,0x84,0xFE,0x82,0xFF,0xB1,0xCF,0xC9,0x87,0x87 + +.endtp1: + +.frame_tiles: + .byte 0x1C,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x1D + .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F + .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F + .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F + .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F + .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F + .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F + .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F + .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F + .byte 0x1E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x1F + +.kbdtable: + ;; This is unfortunate. astorgb and rgbasm cant interpert: + ;; .ascii " !\"#$%&'()*+,-./" + ;; so we have to use the hex form here. + .db 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27 + .db 0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F + .ascii "0123456789:" + ;; astorgb recognises the embedded ; as a comment :) + .db 0x3B + .ascii "<=>?" + .ascii "@ABCDEFGHIJKLMNO" + .ascii "PQRSTUVWXYZ[\]^_" + .ascii "`abcdefghijklmno" + .ascii "pqrstuvwxyz{|}~ " diff --git a/gbdk-lib/libc/gb/joy.s b/gbdk-lib/libc/targets/gbz80/joy.s diff --git a/gbdk-lib/libc/gb/lcd.s b/gbdk-lib/libc/targets/gbz80/lcd.s diff --git a/gbdk-lib/libc/gb/metasprites.s b/gbdk-lib/libc/targets/gbz80/metasprites.s diff --git a/gbdk-lib/libc/gb/metasprites_flip.s b/gbdk-lib/libc/targets/gbz80/metasprites_flip.s diff --git a/gbdk-lib/libc/gb/metasprites_hide.s b/gbdk-lib/libc/targets/gbz80/metasprites_hide.s diff --git a/gbdk-lib/libc/gb/metasprites_hide_spr.s b/gbdk-lib/libc/targets/gbz80/metasprites_hide_spr.s diff --git a/gbdk-lib/libc/gb/mode.s b/gbdk-lib/libc/targets/gbz80/mode.s diff --git a/gbdk-lib/libc/gb/mv_spr.s b/gbdk-lib/libc/targets/gbz80/mv_spr.s diff --git a/gbdk-lib/libc/gb/nowait.s b/gbdk-lib/libc/targets/gbz80/nowait.s diff --git a/gbdk-lib/libc/gb/pad.s b/gbdk-lib/libc/targets/gbz80/pad.s diff --git a/gbdk-lib/libc/gb/pad_ex.s b/gbdk-lib/libc/targets/gbz80/pad_ex.s diff --git a/gbdk-lib/libc/gb/sample.s b/gbdk-lib/libc/targets/gbz80/sample.s diff --git a/gbdk-lib/libc/gb/serial.s b/gbdk-lib/libc/targets/gbz80/serial.s diff --git a/gbdk-lib/libc/gb/set_1bit_data.s b/gbdk-lib/libc/targets/gbz80/set_1bit_data.s diff --git a/gbdk-lib/libc/gb/set_bk_t.s b/gbdk-lib/libc/targets/gbz80/set_bk_t.s diff --git a/gbdk-lib/libc/gb/set_data.s b/gbdk-lib/libc/targets/gbz80/set_data.s diff --git a/gbdk-lib/libc/gb/set_prop.s b/gbdk-lib/libc/targets/gbz80/set_prop.s diff --git a/gbdk-lib/libc/gb/set_spr.s b/gbdk-lib/libc/targets/gbz80/set_spr.s diff --git a/gbdk-lib/libc/gb/set_t.s b/gbdk-lib/libc/targets/gbz80/set_t.s diff --git a/gbdk-lib/libc/gb/set_tile.s b/gbdk-lib/libc/targets/gbz80/set_tile.s diff --git a/gbdk-lib/libc/gb/set_tile_submap.s b/gbdk-lib/libc/targets/gbz80/set_tile_submap.s diff --git a/gbdk-lib/libc/gb/set_wi_t.s b/gbdk-lib/libc/targets/gbz80/set_wi_t.s diff --git a/gbdk-lib/libc/gb/set_win_tile_submap.s b/gbdk-lib/libc/targets/gbz80/set_win_tile_submap.s diff --git a/gbdk-lib/libc/gb/set_xy_t.s b/gbdk-lib/libc/targets/gbz80/set_xy_t.s diff --git a/gbdk-lib/libc/gb/sgb.s b/gbdk-lib/libc/targets/gbz80/sgb.s diff --git a/gbdk-lib/libc/gb/stubs.rasm b/gbdk-lib/libc/targets/gbz80/stubs.rasm diff --git a/gbdk-lib/libc/gb/stubs.s b/gbdk-lib/libc/targets/gbz80/stubs.s diff --git a/gbdk-lib/libc/gb/tim.s b/gbdk-lib/libc/targets/gbz80/tim.s diff --git a/gbdk-lib/libc/targets/z80/__sdcc_bcall.s b/gbdk-lib/libc/targets/z80/__sdcc_bcall.s @@ -0,0 +1,68 @@ + .include "global.s" + + .area _CODE + + .globl ___sdcc_bcall + .globl ___sdcc_bcall_abc + .globl ___sdcc_bcall_ehl +; +; trampoline to call banked functions +; used when legacy banking is enabled only +; Usage: +; call ___sdcc_bcall +; .dw <function> +; .dw <function_bank> +; +___sdcc_bcall:: + ex (sp), hl + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld a, (hl) + inc hl + inc hl + ex (sp), hl +; +; trampoline to call banked functions with __z88dk_fastcall calling convention +; Usage: +; ld a, #<function_bank> +; ld bc, #<function> +; call ___sdcc_bcall_abc +; +___sdcc_bcall_abc:: + push hl + ld l, a + ld a, (#.MAP_FRAME1) + ld h, a + ld a, l + ld (#.MAP_FRAME1), a + ex (sp), hl + inc sp + call ___sdcc_bjump_abc + dec sp + pop af + ld (#.MAP_FRAME1), a + ret +; +___sdcc_bjump_abc: + push bc + ret +; +; default trampoline to call banked functions +; Usage: +; ld e, #<function_bank> +; ld hl, #<function> +; call ___sdcc_bcall_ehl +; +___sdcc_bcall_ehl:: + ld a, (#.MAP_FRAME1) + push af + inc sp + ld a, e + ld (#.MAP_FRAME1), a + CALL_HL + dec sp + pop af + ld (#.MAP_FRAME1), a + ret diff --git a/gbdk-lib/libc/targets/z80/crt0.s b/gbdk-lib/libc/targets/z80/crt0.s @@ -0,0 +1,231 @@ + .include "global.s" + + .title "Runtime" + .module Runtime + .area _HEADER (ABS) + + .globl .CRT_DEFAULT_PALETTE, _set_palette + + .org 0x00 ; Reset 00h + di ; disable interrupt + im 1 ; interrupt mode 1 (this won't change) + jp .init + +; .org 0x08 ; --profile handler + + .org 0x10 ; RST 0x10: SMS_WRITE_VDP_CMD + +_WRITE_VDP_CMD:: + SMS_WRITE_VDP_CMD h, l + ret + +; .org 0x18 ; unusable + + .org 0x20 ; RST 0x20: SMS_WRITE_VDP_DATA + +_WRITE_VDP_DATA:: + SMS_WRITE_VDP_DATA h, l + ret + +; .org 0x28 ; unusable + + .org 0x30 ; RST 0x30: call HL +.call_hl:: + jp (HL) + + .org 0x38 ; handle IRQ + jp _INT_ISR + + .org 0x66 ; handle NMI + jp _NMI_ISR + + .org 0x80 + +.init:: + ld sp, #.STACK ; set stack pointer at end of RAM + + ld a, (#.BIOS) + ld (#__BIOS), a ; save BIOS value + + ld hl, #_shadow_OAM + ld de, #(_shadow_OAM + 1) + ld bc, #64 + ld (hl), #0xc0 + ldir + ld (hl), #0 + ld bc, #(128 - 1) + ldir + + ld hl,#0x0000 ; initialize mappers + ld (#.RAM_CONTROL),hl ; [.RAM_CONTROL]=$00, [.MAP_FRAME0]=$00 + ld hl,#0x0201 + ld (#.MAP_FRAME1),hl ; [.MAP_FRAME1]=$01, [.MAP_FRAME2]=$02 + + ;; Initialise global variables + call .gsinit + + ;; Initialize VDP + ld c, #.VDP_CMD + ld b, #(.shadow_VDP_end - .shadow_VDP) + ld hl,#(.shadow_VDP_end - 1) +1$: + outd + + ld a, b + or #.VDP_REG_MASK + out (c), a + + ld a, b + or a + jr nz, 1$ + + ;; detect PAL/NTSC + + ld c, #.VDP_VCOUNTER +2$: in a, (c) + cp #0x80 + jr nz, 2$ +3$: ld b, a + in a, (c) + cp b + jr nc, 3$ + + ld a, b + cp #0xE8 + ld a, #.SYSTEM_NTSC + jr c, 4$ + ld a, #.SYSTEM_PAL +4$: + ld (#__SYSTEM), a + + ld hl, #.CRT_DEFAULT_PALETTE + push hl + ld hl, #0x0100 + push hl + call _set_palette + ld hl, #.CRT_DEFAULT_PALETTE + push hl + ld hl, #0x0101 + push hl + call _set_palette + + ei ; re-enable interrupts before going to main() + call _main +10$: + halt + jr 10$ + + ;; Ordering of segments for the linker. + .area _HOME + .area _CODE + .area _INITIALIZER + .area _GSINIT + .area _GSFINAL + + .area _DATA + .area _INITIALIZED + .area _BSEG + .area _BSS + .area _HEAP + + .area _CODE + .area _GSINIT +.gsinit:: + ld bc, #l__INITIALIZER + ld a, b + or a, c + jr Z, 1$ + ld de, #s__INITIALIZED + ld hl, #s__INITIALIZER + ldir +1$: + + .area _GSFINAL + ret + + .area _HOME + ;; Wait for VBL interrupt to be finished +.wait_vbl_done:: +_wait_vbl_done:: + ld a, (_shadow_VDP_R1) + and #.R1_DISP_ON + ret z + + xor a + ld (.vbl_done), a +1$: + halt + ld a, (.vbl_done) + or a + jr z, 1$ + ret + + .area _BSS + +.start_crt_globals: +__BIOS:: + .ds 0x01 ; GB type (GB, PGB, CGB) +__SYSTEM:: + .ds 0x01 ; PAL/NTSC +.end_crt_globals: + + .area _INITIALIZED +.shadow_VDP: +_shadow_VDP_R0:: + .ds 0x01 +_shadow_VDP_R1:: + .ds 0x01 +_shadow_VDP_R2:: + .ds 0x01 +_shadow_VDP_R3:: + .ds 0x01 +_shadow_VDP_R4:: + .ds 0x01 +_shadow_VDP_R5:: + .ds 0x01 +_shadow_VDP_R6:: + .ds 0x01 +_shadow_VDP_R7:: +_shadow_VDP_RBORDER:: + .ds 0x01 +_shadow_VDP_R8:: +_shadow_VDP_RSCX:: + .ds 0x01 +_shadow_VDP_R9:: +_shadow_VDP_RSCY:: + .ds 0x01 +_shadow_VDP_R10:: + .ds 0x01 +.shadow_VDP_end:: + +.sys_time:: +_sys_time:: + .ds 0x02 +.vbl_done:: + .ds 0x01 +_VDP_ATTR_SHIFT:: +.vdp_shift:: + .ds 0x01 +__shadow_OAM_base:: + .ds 0x01 +__shadow_OAM_OFF:: + .ds 0x01 + + .area _INITIALIZER + + .db .R0_DEFAULT + .db #(.R1_DEFAULT | .R1_IE) ; VBLANK + .db .R2_MAP_0x3800 + .db 0xFF + .db 0xFF + .db .R5_SAT_0x3F00 + .db .R6_DATA_0x2000 + .db #(0 | .R7_COLOR_MASK) + .db 0 ; SCX + .db 0 ; SCY + .db .R10_INT_OFF + .dw 0x0000 ; .sys_time + .db 0 ; .vbl_done + .db 0 ; _VDP_ATTR_SHIFT + .db #>_shadow_OAM ; __shadow_OAM_base + .db 0 ; __shadow_OAM_OFF + diff --git a/gbdk-lib/libc/targets/z80/gg/Makefile b/gbdk-lib/libc/targets/z80/gg/Makefile @@ -0,0 +1,25 @@ +# GB specific Makefile + +TOPDIR = ../../../.. + +THIS = gg +PORT = z80 + +CSRC = + +ASSRC = outi.s vmemcpy.s \ + set_data.s set_2bpp_data.s \ + set_tile_map.s set_tile_map_xy.s set_tile_map_compat.s set_tile_map_xy_compat.s \ + palette.s \ + pad.s pad_ex.s \ + int.s nmi.s \ + __sdcc_bcall.s \ + crt0.s + +CRT0 = crt0.s + +include $(TOPDIR)/Makefile.common + +AS = $(AS_Z80) + +include ../../../Makefile.platform diff --git a/gbdk-lib/libc/targets/z80/gg/global.s b/gbdk-lib/libc/targets/z80/gg/global.s @@ -0,0 +1,203 @@ + .MEMORY_CTL = 0x3E + + .MEMCTL_JOYON = 0b00000000 + .MEMCTL_JOYOFF = 0b00000100 + .MEMCTL_BASEON = 0b00000000 + .MEMCTL_BASEOFF = 0b00001000 + .MEMCTL_RAMON = 0b00000000 + .MEMCTL_RAMOFF = 0b00010000 + .MEMCTL_CROMON = 0b00000000 + .MEMCTL_CROMOFF = 0b00100000 + .MEMCTL_ROMON = 0b00000000 + .MEMCTL_ROMOFF = 0b01000000 + .MEMCTL_EXTON = 0b00000000 + .MEMCTL_EXTOFF = 0b10000000 + + .JOY_CTL = 0x3F + + .JOY_P1_LATCH = 0b00000010 + .JOY_P2_LATCH = 0b00001000 + + .VDP_VRAM = 0x4000 + .VDP_TILEMAP = 0x7800 + .VDP_CRAM = 0xC000 + .VDP_SAT = 0x7F00 + + .VDP_SAT_TERM = 0xD0 + + .VDP_VCOUNTER = 0x7E + .VDP_PSG = 0x7F + .VDP_HCOUNTER = 0x7F + + .VDP_DATA = 0xBE + .VDP_CMD = 0xBF + .VDP_STAT = 0xBF + + .STATF_INT_VBL = 0b10000000 + .STATF_9_SPR = 0b01000000 + .STATF_SPR_COLL = 0b00100000 + + .VDP_REG_MASK = 0b10000000 + .VDP_R0 = 0b10000000 + + .R0_VSCRL = 0b00000000 + .R0_VSCRL_INH = 0b10000000 + .R0_HSCRL = 0b00000000 + .R0_HSCRL_INH = 0b01000000 + .R0_NO_LCB = 0b00000000 + .R0_LCB = 0b00100000 + .R0_IE1_OFF = 0b00000000 + .R0_IE1 = 0b00010000 + .R0_SS_OFF = 0b00000000 + .R0_SS = 0b00001000 + .R0_DEFAULT = 0b00000110 + .R0_ES_OFF = 0b00000000 + .R0_ES = 0b00000001 + + .VDP_R1 = 0b10000001 + + .R1_DEFAULT = 0b10000000 + .R1_DISP_OFF = 0b00000000 + .R1_DISP_ON = 0b01000000 + .R1_IE_OFF = 0b00000000 + .R1_IE = 0b00100000 + .R1_SPR_8X8 = 0b00000000 + .R1_SPR_8X16 = 0b00000010 + + .VDP_R2 = 0b10000010 + + .R2_MAP_0x3800 = 0xFF + .R2_MAP_0x3000 = 0xFD + .R2_MAP_0x2800 = 0xFB + .R2_MAP_0x2000 = 0xF9 + .R2_MAP_0x1800 = 0xF7 + .R2_MAP_0x1000 = 0xF5 + .R2_MAP_0x0800 = 0xF3 + .R2_MAP_0x0000 = 0xF1 + + .VDP_R3 = 0b10000011 + .VDP_R4 = 0b10000100 + .VDP_R5 = 0b10000101 + + .R5_SAT_0x3F00 = 0xFF + .R5_SAT_MASK = 0b10000001 + + .VDP_R6 = 0b10000110 + + .R6_BANK0 = 0xFB + .R6_DATA_0x0000 = 0xFB + .R6_BANK1 = 0xFF + .R6_DATA_0x2000 = 0xFF + + .VDP_R7 = 0b10000111 + .VDP_RBORDER = 0b10000111 + + .R7_COLOR_MASK = 0b11110000 + + .VDP_R8 = 0b10001000 + .VDP_RSCX = 0b10001000 + + .VDP_R9 = 0b10001001 + .VDP_RSCY = 0b10001001 + + .VDP_R10 = 0b10001010 + + .R10_INT_OFF = 0xFF + .R10_INT_EVERY = 0x00 + + .UP = 0b00000001 + .DOWN = 0b00000010 + .LEFT = 0b00000100 + .RIGHT = 0b00001000 + .A = 0b00010000 + .B = 0b00100000 + .SELECT = 0b01000000 ; map to RESET + .START = 0b01000000 ; map to RESET + + .JOY_PORT1 = 0xDC + + .JOY_P1_UP = 0b00000001 + .JOY_P1_DOWN = 0b00000010 + .JOY_P1_LEFT = 0b00000100 + .JOY_P1_RIGHT = 0b00001000 + .JOY_P1_SW1 = 0b00010000 + .JOY_P1_TRIGGER = 0b00010000 + .JOY_P1_SW2 = 0b00100000 + .JOY_P2_UP = 0b01000000 + .JOY_P2_DOWN = 0b10000000 + + .JOY_PORT2 = 0xDD + + .JOY_P2_LEFT = 0b00000001 + .JOY_P2_RIGHT = 0b00000010 + .JOY_P2_SW1 = 0b00000100 + .JOY_P2_TRIGGER = 0b00000100 + .JOY_P2_SW2 = 0b00001000 + .JOY_RESET = 0b00010000 + .JOY_P1_LIGHT = 0b01000000 + .JOY_P2_LIGHT = 0b10000000 + + .FMADDRESS = 0xF0 + .FMDATA = 0xF1 + .AUDIOCTRL = 0xF2 + + .RAM_CONTROL = 0xfffc + + .RAMCTL_BANK = 0b00000100 + .RAMCTL_ROM = 0b00000000 + .RAMCTL_RAM = 0b00001000 + .RAMCTL_RO = 0b00010000 + .RAMCTL_PROT = 0b10000000 + + .GLASSES_3D = 0xfff8 + + .MAP_FRAME0 = 0xfffd + .MAP_FRAME1 = 0xfffe + .MAP_FRAME2 = 0xffff + + .BIOS = 0xC000 + + .SYSTEM_PAL = 0x00 + .SYSTEM_NTSC = 0x01 + + ;; Interrupt routines + .globl _INT_ISR + .globl _NMI_ISR + + ;; Symbols defined at link time + .globl .STACK + .globl _shadow_OAM + .globl __shadow_OAM_OFF + + ;; Main user routine + .globl _main + + ;; Macro definitions + +.macro SMS_WRITE_VDP_DATA regH regL ?lbl + ld a, i + ld a, regL + di + out (#.VDP_DATA), a ; 11 + ld a, regH ; 4 + jp po, lbl ; 7/12 + ei ; 4 (total: 26/27) +lbl: + out (#.VDP_DATA), a +.endm + +.macro SMS_WRITE_VDP_CMD regH regL ?lbl + ld a, i + ld a, regL + di + out (#.VDP_CMD), a + ld a, regH + jp po, lbl + ei +lbl: + out (#.VDP_CMD), a +.endm + +.macro CALL_HL + rst 0x30 +.endm diff --git a/gbdk-lib/libc/targets/z80/gg/nmi.s b/gbdk-lib/libc/targets/z80/gg/nmi.s @@ -0,0 +1,8 @@ + .include "global.s" + + .title "NMI Handler" + .module NMIHandler + .area _HOME + +_NMI_ISR:: + retn + diff --git a/gbdk-lib/libc/targets/z80/gg/palette.s b/gbdk-lib/libc/targets/z80/gg/palette.s @@ -0,0 +1,109 @@ + ;; SMS palette routines + + .include "global.s" + + .title "CRAM SMS Palettes" + .module CRAMUtils + .area _HOME + +; void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) __z88dk_callee; +_set_palette_entry:: + pop de + pop bc + ld hl, #.VDP_CRAM + bit 0, c + jr z, 1$ + set 4, b +1$: + sla b + ld c, b + ld b, #0 + add hl, bc + pop bc + + ld a, i + di + ld a, l + out (#.VDP_CMD), a + ld a, h + out (#.VDP_CMD), a + ld a, c + out (#.VDP_DATA), a + jr 3$ +3$: + ld a, b + out (#.VDP_DATA), a + jp po, 2$ + ei +2$: + ld h, d + ld l, e + jp (hl) + +; void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee; +_set_palette:: + pop de + pop bc + ld hl, #.VDP_CRAM + bit 0, c + ld a, b + ld bc, #0 + jr z, 1$ + ld c, #0x20 +1$: + add hl, bc + + ld c, a + + ld a, #0x01 + ld (__shadow_OAM_OFF), a ; switch OFF copy shadow SAT + + ld a, i + di + ld a, l + out (#.VDP_CMD), a + ld a, h + out (#.VDP_CMD), a + jp po, 2$ + ei +2$: + ld a, c + or a + jr z, 3$ + + pop hl + ld c, #.VDP_DATA +5$: + ld b, #0x20 +4$: + outi + jr nz, 4$ + + dec a + jr nz, 5$ +3$: + xor a + ld (__shadow_OAM_OFF), a ; switch ON copy shadow SAT + + ld h, d + ld l, e + jp (hl) + +.CRT_DEFAULT_PALETTE:: + .dw 0b0000000000000000 + .dw 0b0000010001000100 + .dw 0b0000100010001000 + .dw 0b0000111111111111 + .dw 0b0000000000001000 + .dw 0b0000000010000000 + .dw 0b0000100000000000 + .dw 0b0000000010001000 + .dw 0b0000100010000000 + .dw 0b0000100000001000 + .dw 0b0000000000001111 + .dw 0b0000000011110000 + .dw 0b0000111100000000 + .dw 0b0000000011111111 + .dw 0b0000111111110000 + .dw 0b0000111100001111 + diff --git a/gbdk-lib/libc/targets/z80/int.s b/gbdk-lib/libc/targets/z80/int.s @@ -0,0 +1,197 @@ + .include "global.s" + + .title "INT Handler" + .module INTHandler + + .globl .sys_time, .vbl_done + .globl .OUTI128, .OUTI64, __shadow_OAM_base + + .area _HOME + +_INT_ISR:: + push af + push bc + push de + push hl + push iy + push ix + + in a, (.VDP_STAT) + and #.STATF_INT_VBL + jp z, 0$ + ;; handle VBlank + + ld hl, (.sys_time) + inc hl + ld (.sys_time), hl + + ld a, #1 + ld (.vbl_done), a + + ;; transfer shadow OAM + ld a, (__shadow_OAM_OFF) ; check transfer is OFF + or a + jp nz, 0$ + ld hl, #__shadow_OAM_base + ld h, (hl) + ld l, a ; a == 0 here + + ld c, #.VDP_CMD + ld a, #<.VDP_SAT + out (c), a + ld a, #>.VDP_SAT + out (c), a + dec c ; c == .VDP_DATA + call .OUTI64 + inc c ; c == .VDP_CMD + ld a, #<(.VDP_SAT + 0x80) + out (c), a + ld a, #>(.VDP_SAT + 0x80) + out (c), a + dec c ; c == .VDP_DATA + call .OUTI128 +0$: + + ;; call user-defined VBlank handlers + ld hl, (.VBLANK_HANDLER0) + ld a, h + or l + jp z, 2$ + CALL_HL + + ld hl, (.VBLANK_HANDLER1) + ld a, h + or l + jp z, 2$ + CALL_HL + + ld hl, (.VBLANK_HANDLER2) + ld a, h + or l + jp z, 2$ + CALL_HL + jp 2$ + + ;; handle HBlank +1$: + ld hl, (.HBLANK_HANDLER0) + CALL_HL + +2$: + pop ix + pop iy + pop hl + pop de + pop bc + pop af + ei + reti + +; void add_LCD (int_handler h) __z88dk_fastcall __preserves_regs(b, c, iyh, iyl); +_add_LCD:: +.add_LCD:: + ld (.HBLANK_HANDLER0), hl + ret + +; void remove_LCD (int_handler h) __z88dk_fastcall __preserves_regs(b, c, iyh, iyl); +_remove_LCD:: +.remove_LCD:: + ld hl, #.empty_function + ld (.HBLANK_HANDLER0), hl + ret + +; void add_VBL(int_handler h) __z88dk_fastcall __preserves_regs(d, e, iyh, iyl); +_add_VBL:: + ld b, h + ld c, l + +.add_VBL:: + ld hl, #.VBLANK_HANDLER0 + + ;; Add interrupt routine in BC to the interrupt list in HL +.add_int:: +1$: + ld a, (hl) + inc hl + or (hl) + jr z, 2$ + inc hl + jr 1$ +2$: + ld (hl), b + dec hl + ld (hl), c + ret + +; void remove_VBL(int_handler h) __z88dk_fastcall __preserves_regs(iyh, iyl); +_remove_VBL:: + ld b, h + ld c, l + + ;; Remove interrupt routine in BC from the VBL interrupt list + ;; falldown to .remove_int +.remove_VBL:: + ld hl, #.VBLANK_HANDLER0 + + ;; Remove interrupt BC from interrupt list HL if it exists + ;; Abort if a 0000 is found (end of list) +.remove_int:: +1$: + ld e, (hl) + inc hl + ld d, (hl) + inc hl + ld a, e + or d + ret z ; No interrupt found + + ld a, e + cp c + jr nz, 1$ + + ld a, d + cp b + jr nz, 1$ + + ld d, h + ld e, l + dec de + dec de + + ;; Now do a memcpy from here until the end of the list +2$: + ld a, (hl) + ldi + or (hl) + ldi + jr nz, 2$ + ret + +_remove_TIM:: +_remove_SIO:: +_remove_JOY:: +_add_TIM:: +_add_SIO:: +_add_JOY:: +.empty_function: + ret + + .area _INITIALIZED + +.HBLANK_HANDLER0: + .ds 0x02 +.VBLANK_HANDLER0: + .ds 0x02 +.VBLANK_HANDLER1: + .ds 0x02 +.VBLANK_HANDLER2: + .ds 0x02 + .ds 0x02 + + .area _INITIALIZER + + .dw .empty_function + .dw 0x0000 + .dw 0x0000 + .dw 0x0000 + .dw 0x0000 diff --git a/gbdk-lib/libc/targets/z80/outi.s b/gbdk-lib/libc/targets/z80/outi.s @@ -0,0 +1,20 @@ + .include "global.s" + + .title "VRAM utilities" + .module VRAMUtils + .area _HOME + +.OUTI128:: ; _OUTI128 label points to a block of 128 OUTI and a RET + .rept 64 + outi + .endm +.OUTI64:: ; _OUTI64 label points to a block of 64 OUTI and a RET + .rept 32 + outi + .endm +.OUTI32:: ; _OUTI32 label points to a block of 32 OUTI and a RET + .rept 32 + outi + .endm +.OUTI_END:: ; _outi_block label points to END of OUTI block + ret diff --git a/gbdk-lib/libc/targets/z80/pad.s b/gbdk-lib/libc/targets/z80/pad.s @@ -0,0 +1,38 @@ + .include "global.s" + + .title "JOYPad utilities" + .module JOYPad + .area _HOME + + ;; Get Keypad Button Status +_joypad:: +.jpad:: + in a, (#.JOY_PORT1) + cpl + and #0b00111111 + ld l, a + ret + + ;; Wait until all buttons have been released +.padup:: +_waitpadup:: +1$: + ld h,#0x7f ; wait for .jpad return zero 127 times in a row +2$: + call .jpad + or a ; have all buttons been released? + jr nz,1$ ; not yet + + dec h + jr nz,2$ + + ret + + ;; Wait for the key to be pressed +_waitpad:: +.wait_pad:: +1$: + call .jpad ; read pad + and l ; compare with mask? + jr z,1$ ; loop if no intersection + ret diff --git a/gbdk-lib/libc/targets/z80/pad_ex.s b/gbdk-lib/libc/targets/z80/pad_ex.s @@ -0,0 +1,63 @@ + .include "global.s" + + .title "JOYPad utilities" + .module JOYPad + .area _HOME + +; uint8_t joypad_init(uint8_t npads, joypads_t * joypads) __z88dk_callee; +_joypad_init:: + ld hl, #2 + add hl, sp + ld a, (hl) + and #3 + inc hl + ld e, (hl) + inc hl + ld d, (hl) + + inc hl + pop bc ; pop return address + ld sp, hl ; dispose params + push bc ; push return address back + + ld (de), a ; number of joypads + ld l, a ; return number of joypads in l + xor a + inc de + ld (de), a + inc de + ld (de), a + inc de + ld (de), a + inc de + ld (de), a + + ret + +;void joypad_ex(joypads_t * joypads) __z88dk_fastcall; + +_joypad_ex:: + ld c, #.JOY_PORT1 + in e, (c) + inc c + in d, (c) + ld a, e + rla + rl d + rla + rl d + ld a, e + cpl + and #0b00111111 + ld e, a + ld a, d + cpl + and #0b01111111 + ld d, a + + inc hl + ld (hl), e + inc hl + ld (hl), d + + ret + diff --git a/gbdk-lib/libc/targets/z80/set_2bpp_data.s b/gbdk-lib/libc/targets/z80/set_2bpp_data.s @@ -0,0 +1,67 @@ + .include "global.s" + + .title "VRAM utilities" + .module VRAMUtils + .area _HOME + +; void set_tile_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); +_set_tile_2bpp_data:: + pop de ; pop ret address + pop hl + + add hl, hl + add hl, hl + add hl, hl + add hl, hl + add hl, hl + + ld bc, #.VDP_VRAM + add hl, bc + + ld a, #0x01 + ld (__shadow_OAM_OFF), a ; switch OFF copy shadow SAT + + SMS_WRITE_VDP_CMD h, l + + pop bc + pop hl + push de + + ld e, c + ld d, b + + ld c, #.VDP_DATA + inc d + inc e + xor a + jr 2$ + +1$: + ld b, #16 +3$: + outi + jr 4$ +4$: + outi + jr 5$ +5$: + nop + out (c), a + jr 6$ +6$: + nop + nop + out (c), a + nop + jr nz, 3$ +2$: + dec e + jr nz, 1$ + + dec d + jr nz, 1$ + + xor a + ld (__shadow_OAM_OFF), a ; switch ON copy shadow SAT + + ret diff --git a/gbdk-lib/libc/targets/z80/set_data.s b/gbdk-lib/libc/targets/z80/set_data.s @@ -0,0 +1,53 @@ + .include "global.s" + + .title "VRAM utilities" + .module VRAMUtils + .area _HOME + +; void set_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); +_set_tile_data:: + pop de ; pop ret address + pop hl + + add hl, hl + add hl, hl + add hl, hl + add hl, hl + add hl, hl + + ld bc, #.VDP_VRAM + add hl, bc + + ld a, #0x01 + ld (__shadow_OAM_OFF), a ; switch OFF copy shadow SAT + + SMS_WRITE_VDP_CMD h, l + + pop bc + pop hl + push de + + ld e, c + ld d, b + + ld c, #.VDP_DATA + inc d + inc e + jr 2$ + +1$: + ld b, #32 +3$: + outi + jr nz, 3$ +2$: + dec e + jr nz, 1$ + + dec d + jr nz, 1$ + + xor a + ld (__shadow_OAM_OFF), a ; switch ON copy shadow SAT + + ret diff --git a/gbdk-lib/libc/targets/z80/set_tile_map.s b/gbdk-lib/libc/targets/z80/set_tile_map.s @@ -0,0 +1,24 @@ + .include "global.s" + + .globl .set_tile_map_xy + ;; BANKED: checked + .area _HOME + +; void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) __z88dk_callee __preserves_regs(iyh, iyl); +_set_tile_map:: + + pop hl ; HL = ret + pop bc ; BC = YX + pop de ; DE = WH + ex (sp), hl ; HL = data + ex de, hl ; HL = WH, DE = data + ld a, b + ld b, d + ld d, a + ld a, c + ld c, e + ld e, a ; BC = data, DE = YX + + call .set_tile_map_xy + + ret + diff --git a/gbdk-lib/libc/targets/z80/set_tile_map_compat.s b/gbdk-lib/libc/targets/z80/set_tile_map_compat.s @@ -0,0 +1,24 @@ + .include "global.s" + + .globl .set_tile_map_xy + ;; BANKED: checked + .area _HOME + +; void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) __z88dk_callee __preserves_regs(iyh, iyl); +_set_tile_map_compat:: + + pop hl ; HL = ret + pop bc ; BC = YX + pop de ; DE = WH + ex (sp), hl ; HL = data + ex de, hl ; HL = WH, DE = data + ld a, b + ld b, d + ld d, a + ld a, c + ld c, e + ld e, a ; BC = data, DE = YX + + call .set_tile_map_xy_compat + + ret + diff --git a/gbdk-lib/libc/targets/z80/set_tile_map_xy.s b/gbdk-lib/libc/targets/z80/set_tile_map_xy.s @@ -0,0 +1,82 @@ + .include "global.s" + + .title "VRAM utilities" + .module VRAMUtils + .area _HOME + + ;; Set background tile table from (BC) at XY = DE of size WH = HL +.set_tile_map_xy:: + push hl + ld hl, #.VDP_TILEMAP + + ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL) +.set_tile_map_xy_tt:: + push bc ; Store source + + ld a, d + rlca + rlca + rlca + rlca + rlca + rlca + ld d, a + and #0x07 + add h + ld b, a + ld a, #0xC0 + and d + sla e + add e + ld c, a ; dest BC = HL + ((0x20 * Y) * 2) + (X * 2) + + ld a, b + cp #>(.VDP_TILEMAP+0x0700) + jr c, 5$ + ld b, #>.VDP_TILEMAP +5$: + + pop hl ; HL = source + pop de ; DE = HW + sla e + push de ; store HW + push bc ; store dest + + ld a, #0x01 + ld (__shadow_OAM_OFF), a ; switch OFF copy shadow SAT + +1$: ; copy H rows + SMS_WRITE_VDP_CMD b, c + ld c, #.VDP_DATA + ld b, e +2$: ; copy W tiles + outi + jr 3$ +3$: + outi + jr nz, 2$ + + pop bc + pop de + dec d + jr z, 6$ + + push de + + ld a, #0x40 + add c + ld c, a + adc b + sub c + ld b, a + + cp #>(.VDP_TILEMAP+0x0700) + jr c, 4$ + ld b, #>.VDP_TILEMAP +4$: + push bc + jr 1$ +6$: + xor a + ld (__shadow_OAM_OFF), a ; switch ON copy shadow SAT + ret + diff --git a/gbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s b/gbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s @@ -0,0 +1,89 @@ + .include "global.s" + + .globl .vdp_shift + + .title "VRAM utilities" + .module VRAMUtils + .area _HOME + + ;; Set background tile table from (BC) at XY = DE of size WH = HL +.set_tile_map_xy_compat:: + push hl + ld hl, #.VDP_TILEMAP + + ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL) +.set_tile_map_xy_tt_compat:: + push bc ; Store source + + ld a, d + rlca + rlca + rlca + rlca + rlca + rlca + ld d, a + and #0x07 + add h + ld b, a + ld a, #0xC0 + and d + sla e + add e + ld hl, #.vdp_shift + add (hl) + ld c, a ; dest BC = HL + ((0x20 * Y) * 2) + (X * 2) + + ld a, b + cp #>(.VDP_TILEMAP+0x0700) + jr c, 5$ + ld b, #>.VDP_TILEMAP +5$: + dec bc + + pop hl ; HL = source + pop de ; DE = HW + push de ; store HW + push bc ; store dest + + ld a, #0x01 + ld (__shadow_OAM_OFF), a ; switch OFF copy shadow SAT + +1$: ; copy H rows + SMS_WRITE_VDP_CMD b, c + ld c, #.VDP_DATA + ld b, e +2$: ; copy W tiles + in a, (c) ; skip next byte + nop + jr 3$ +3$: + outi + nop + jr nz, 2$ + + pop bc + pop de + dec d + jr z, 6$ + + push de + + ld a, #0x40 + add c + ld c, a + adc b + sub c + ld b, a + + cp #>(.VDP_TILEMAP+0x0700) + jr c, 4$ + ld b, #>.VDP_TILEMAP +4$: + push bc + jr 1$ +6$: + xor a + ld (__shadow_OAM_OFF), a ; switch ON copy shadow SAT + + ret + diff --git a/gbdk-lib/libc/targets/z80/sms/Makefile b/gbdk-lib/libc/targets/z80/sms/Makefile @@ -0,0 +1,25 @@ +# GB specific Makefile + +TOPDIR = ../../../.. + +THIS = sms +PORT = z80 + +CSRC = + +ASSRC = outi.s vmemcpy.s \ + set_data.s set_2bpp_data.s \ + set_tile_map.s set_tile_map_xy.s set_tile_map_compat.s set_tile_map_xy_compat.s \ + palette.s \ + pad.s pad_ex.s \ + int.s nmi.s \ + __sdcc_bcall.s \ + crt0.s + +CRT0 = crt0.s + +include $(TOPDIR)/Makefile.common + +AS = $(AS_Z80) + +include ../../../Makefile.platform diff --git a/gbdk-lib/libc/targets/z80/sms/global.s b/gbdk-lib/libc/targets/z80/sms/global.s @@ -0,0 +1,201 @@ + .MEMORY_CTL = 0x3E + + .MEMCTL_JOYON = 0b00000000 + .MEMCTL_JOYOFF = 0b00000100 + .MEMCTL_BASEON = 0b00000000 + .MEMCTL_BASEOFF = 0b00001000 + .MEMCTL_RAMON = 0b00000000 + .MEMCTL_RAMOFF = 0b00010000 + .MEMCTL_CROMON = 0b00000000 + .MEMCTL_CROMOFF = 0b00100000 + .MEMCTL_ROMON = 0b00000000 + .MEMCTL_ROMOFF = 0b01000000 + .MEMCTL_EXTON = 0b00000000 + .MEMCTL_EXTOFF = 0b10000000 + + .JOY_CTL = 0x3F + + .JOY_P1_LATCH = 0b00000010 + .JOY_P2_LATCH = 0b00001000 + + .VDP_VRAM = 0x4000 + .VDP_TILEMAP = 0x7800 + .VDP_CRAM = 0xC000 + .VDP_SAT = 0x7F00 + + .VDP_SAT_TERM = 0xD0 + + .VDP_VCOUNTER = 0x7E + .VDP_PSG = 0x7F + .VDP_HCOUNTER = 0x7F + + .VDP_DATA = 0xBE + .VDP_CMD = 0xBF + .VDP_STAT = 0xBF + + .STATF_INT_VBL = 0b10000000 + .STATF_9_SPR = 0b01000000 + .STATF_SPR_COLL = 0b00100000 + + .VDP_REG_MASK = 0b10000000 + .VDP_R0 = 0b10000000 + + .R0_VSCRL = 0b00000000 + .R0_VSCRL_INH = 0b10000000 + .R0_HSCRL = 0b00000000 + .R0_HSCRL_INH = 0b01000000 + .R0_NO_LCB = 0b00000000 + .R0_LCB = 0b00100000 + .R0_IE1_OFF = 0b00000000 + .R0_IE1 = 0b00010000 + .R0_SS_OFF = 0b00000000 + .R0_SS = 0b00001000 + .R0_DEFAULT = 0b00000110 + .R0_ES_OFF = 0b00000000 + .R0_ES = 0b00000001 + + .VDP_R1 = 0b10000001 + + .R1_DEFAULT = 0b10000000 + .R1_DISP_OFF = 0b00000000 + .R1_DISP_ON = 0b01000000 + .R1_IE_OFF = 0b00000000 + .R1_IE = 0b00100000 + .R1_SPR_8X8 = 0b00000000 + .R1_SPR_8X16 = 0b00000010 + + .VDP_R2 = 0b10000010 + + .R2_MAP_0x3800 = 0xFF + .R2_MAP_0x3000 = 0xFD + .R2_MAP_0x2800 = 0xFB + .R2_MAP_0x2000 = 0xF9 + .R2_MAP_0x1800 = 0xF7 + .R2_MAP_0x1000 = 0xF5 + .R2_MAP_0x0800 = 0xF3 + .R2_MAP_0x0000 = 0xF1 + + .VDP_R3 = 0b10000011 + .VDP_R4 = 0b10000100 + .VDP_R5 = 0b10000101 + + .R5_SAT_0x3F00 = 0xFF + .R5_SAT_MASK = 0b10000001 + + .VDP_R6 = 0b10000110 + + .R6_BANK0 = 0xFB + .R6_DATA_0x0000 = 0xFB + .R6_BANK1 = 0xFF + .R6_DATA_0x2000 = 0xFF + + .VDP_R7 = 0b10000111 + .VDP_RBORDER = 0b10000111 + + .R7_COLOR_MASK = 0b11110000 + + .VDP_R8 = 0b10001000 + .VDP_RSCX = 0b10001000 + + .VDP_R9 = 0b10001001 + .VDP_RSCY = 0b10001001 + + .VDP_R10 = 0b10001010 + + .R10_INT_OFF = 0xFF + .R10_INT_EVERY = 0x00 + + .UP = 0b00000001 + .DOWN = 0b00000010 + .LEFT = 0b00000100 + .RIGHT = 0b00001000 + .A = 0b00010000 + .B = 0b00100000 + .SELECT = 0b01000000 ; map to RESET + .START = 0b01000000 ; map to RESET + + .JOY_PORT1 = 0xDC + + .JOY_P1_UP = 0b00000001 + .JOY_P1_DOWN = 0b00000010 + .JOY_P1_LEFT = 0b00000100 + .JOY_P1_RIGHT = 0b00001000 + .JOY_P1_SW1 = 0b00010000 + .JOY_P1_TRIGGER = 0b00010000 + .JOY_P1_SW2 = 0b00100000 + .JOY_P2_UP = 0b01000000 + .JOY_P2_DOWN = 0b10000000 + + .JOY_PORT2 = 0xDD + + .JOY_P2_LEFT = 0b00000001 + .JOY_P2_RIGHT = 0b00000010 + .JOY_P2_SW1 = 0b00000100 + .JOY_P2_TRIGGER = 0b00000100 + .JOY_P2_SW2 = 0b00001000 + .JOY_RESET = 0b00010000 + .JOY_P1_LIGHT = 0b01000000 + .JOY_P2_LIGHT = 0b10000000 + + .FMADDRESS = 0xF0 + .FMDATA = 0xF1 + .AUDIOCTRL = 0xF2 + + .RAM_CONTROL = 0xfffc + + .RAMCTL_BANK = 0b00000100 + .RAMCTL_ROM = 0b00000000 + .RAMCTL_RAM = 0b00001000 + .RAMCTL_RO = 0b00010000 + .RAMCTL_PROT = 0b10000000 + + .MAP_FRAME0 = 0xfffd + .MAP_FRAME1 = 0xfffe + .MAP_FRAME2 = 0xffff + + .BIOS = 0xC000 + + .SYSTEM_PAL = 0x00 + .SYSTEM_NTSC = 0x01 + + ;; Interrupt routines + .globl _INT_ISR + .globl _NMI_ISR + + ;; Symbols defined at link time + .globl .STACK + .globl _shadow_OAM + .globl __shadow_OAM_OFF + + ;; Main user routine + .globl _main + + ;; Macro definitions + +.macro SMS_WRITE_VDP_DATA regH regL ?lbl + ld a, i + ld a, regL + di + out (#.VDP_DATA), a ; 11 + ld a, regH ; 4 + jp po, lbl ; 7/12 + ei ; 4 (total: 26/27) +lbl: + out (#.VDP_DATA), a +.endm + +.macro SMS_WRITE_VDP_CMD regH regL ?lbl + ld a, i + ld a, regL + di + out (#.VDP_CMD), a + ld a, regH + jp po, lbl + ei +lbl: + out (#.VDP_CMD), a +.endm + +.macro CALL_HL + rst 0x30 +.endm diff --git a/gbdk-lib/libc/targets/z80/sms/nmi.s b/gbdk-lib/libc/targets/z80/sms/nmi.s @@ -0,0 +1,8 @@ + .include "global.s" + + .title "NMI Handler" + .module NMIHandler + .area _HOME + +_NMI_ISR:: + retn + diff --git a/gbdk-lib/libc/targets/z80/sms/palette.s b/gbdk-lib/libc/targets/z80/sms/palette.s @@ -0,0 +1,105 @@ + ;; SMS palette routines + + .include "global.s" + + .title "CRAM SMS Palettes" + .module CRAMUtils + .area _HOME + +; void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) __z88dk_callee; +_set_palette_entry:: + pop de + pop bc + ld hl, #.VDP_CRAM + bit 0, c + jr z, 1$ + set 4, b +1$: + ld c, b + ld b, #0 + add hl, bc + pop bc + + ld a, i + di + ld a, l + out (#.VDP_CMD), a + ld a, h + out (#.VDP_CMD), a + ld a, c + jp po, 2$ + ei +2$: + out (#.VDP_DATA), a + + ld h, d + ld l, e + jp (hl) + +; void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee; +_set_palette:: + pop de + pop bc + ld hl, #.VDP_CRAM + bit 0, c + ld a, b + ld bc, #0 + jr z, 1$ + ld c, #0x10 +1$: + add hl, bc + + ld c, a + + ld a, #0x01 + ld (__shadow_OAM_OFF), a ; switch OFF copy shadow SAT + + ld a, i + di + ld a, l + out (#.VDP_CMD), a + ld a, h + out (#.VDP_CMD), a + jp po, 2$ + ei +2$: + ld a, c + or a + jr z, 3$ + + pop hl + ld c, #.VDP_DATA +5$: + ld b, #0x10 +4$: + outi + jr nz, 4$ + + dec a + jr nz, 5$ +3$: + xor a + ld (__shadow_OAM_OFF), a ; switch ON copy shadow SAT + + ld h, d + ld l, e + jp (hl) + +.CRT_DEFAULT_PALETTE:: + .db 0b00000000 + .db 0b00010101 + .db 0b00101010 + .db 0b00111111 + .db 0b00000010 + .db 0b00001000 + .db 0b00100000 + .db 0b00001010 + .db 0b00101000 + .db 0b00100010 + .db 0b00000011 + .db 0b00001100 + .db 0b00110000 + .db 0b00001111 + .db 0b00111100 + .db 0b00110011 + diff --git a/gbdk-lib/libc/targets/z80/vmemcpy.s b/gbdk-lib/libc/targets/z80/vmemcpy.s @@ -0,0 +1,41 @@ + .include "global.s" + + .title "VRAM utilities" + .module VRAMUtils + .area _HOME + +; void vmemcpy (unsigned int dst, const void *src, unsigned int size) __z88dk_callee __preserves_regs(iyh,iyl); +_vmemcpy:: + pop de ; pop ret address + pop hl ; dst + + SMS_WRITE_VDP_CMD h, l + + pop hl ; src + pop bc ; size + + dec bc + + ld a, b ; HI(size) + ld b, c ; LO(size) + + inc a + + ld c, #.VDP_DATA + + rlc b + rrc b ; check b is zero + jr z, 2$ + + inc b + +1$: + outi + jp nz, 1$ ; 10 = 26 (VRAM safe) +2$: + dec a + jp nz, 1$ + + ld h, d + ld l, e + jp (hl) diff --git a/gbdk-support/bankpack/bankpack.c b/gbdk-support/bankpack/bankpack.c @@ -41,6 +41,7 @@ static void display_help(void) { "-sym=<prefix>: Add symbols starting with <prefix> to match + update list.\n" " Default entry is \"___bank_\" (see below)\n" "-cartsize : Print min required cart size as \"autocartsize:<NNN>\"\n" + "-plat=<plat> : Select platform specific behavior (default:gb) (gb,sms)\n" "-v : Verbose output, show assignments\n" "\n" "Example: \"bankpack -ext=.rel -path=some/newpath/ file1.o file2.o\"\n" @@ -97,6 +98,8 @@ static int handle_args(int argc, char * argv[]) { symbol_match_add(argv[i] + 5); } else if (strstr(argv[i], "-cartsize") == argv[i]) { g_option_cartsize = true; + } else if (strstr(argv[i], "-plat=") == argv[i]) { + banks_set_platform(argv[i] + 6); } else printf("BankPack: Warning: Ignoring unknown option %s\n", argv[i]); } else { @@ -143,7 +146,11 @@ int main( int argc, char *argv[] ) { if (handle_args(argc, argv)) { - if (banks_get_mbc_type() != MBC_TYPE_NONE) { + // Require MBC for Game Boy + // SMS doesn't require an MBC setting + if ((banks_get_platform() == PLATFORM_GB) && (banks_get_mbc_type() == MBC_TYPE_NONE)) + printf("BankPack: ERROR: auto-banking does not work with unbanked ROMS (no MBC for Game Boy)\n"); + else { // Extract areas, sort and assign them to banks // then rewrite object files as needed files_extract(); @@ -156,8 +163,7 @@ int main( int argc, char *argv[] ) { cleanup(); ret = EXIT_SUCCESS; - } else - printf("BankPack: ERROR: auto-banking does not work with unbanked ROMS (no MBC)\n"); + } } return ret; // Exit with failure by default diff --git a/gbdk-support/bankpack/files.c b/gbdk-support/bankpack/files.c @@ -52,6 +52,7 @@ void files_add(char * filename) { if (snprintf(newfile.name_in, sizeof(newfile.name_in), "%s", filename) > sizeof(newfile.name_in)) printf("Warning: truncated input filename to:%s\n",newfile.name_in); + newfile.name_out[0] = '\0'; newfile.rewrite_needed = false; newfile.bank_num = BANK_NUM_UNASSIGNED; @@ -66,7 +67,7 @@ char * file_get_name_in_by_id(uint32_t file_id) { if ((file_id >= 0) && (file_id < filelist.count)) return files[file_id].name_in; else - return NULL; + return (char *)"\0"; } @@ -77,7 +78,7 @@ char * file_get_name_out_by_id(uint32_t file_id) { if ((file_id >= 0) && (file_id < filelist.count)) return files[file_id].name_out; else - return NULL; + return (char *)"\0"; } diff --git a/gbdk-support/bankpack/obj_data.c b/gbdk-support/bankpack/obj_data.c @@ -43,6 +43,27 @@ uint16_t bank_assign_rom_max = 0; uint16_t bank_all_rom_max = 0; int g_mbc_type = MBC_TYPE_DEFAULT; +int g_platform = PLATFORM_DEFAULT; + + +int banks_get_platform(void) { + return g_platform; +} + +void banks_set_platform(char * platform_str) { + + if (strcmp(platform_str, PLATFORM_STR_GB) == 0) + g_platform = PLATFORM_GB; + else if (strcmp(platform_str, PLATFORM_STR_AP) == 0) + g_platform = PLATFORM_GB; // AP uses GB platform + else if (strcmp(platform_str, PLATFORM_STR_SMS) == 0) + g_platform = PLATFORM_SMS; + else if (strcmp(platform_str, PLATFORM_STR_GG) == 0) + g_platform = PLATFORM_SMS; // GG uses SMS platform + else + printf("BankPack: Warning: Invalid platform option %s\n", platform_str); +} + int banks_get_mbc_type(void) { @@ -215,6 +236,7 @@ void obj_data_init(void) { // Pre-populate bank list with max number of of banks // to allow handling fixed-bank (non-autobank) areas newbank.size = newbank.free = BANK_SIZE_ROM; + newbank.type = BANK_TYPE_UNSET; for (c=0; c < BANK_ROM_TOTAL; c++) list_additem(&banklist, &newbank); @@ -249,20 +271,30 @@ int areas_add(char * area_str, uint32_t file_id) { area_item newarea; - // Only match areas which are banked ("_CODE_" vs "_CODE") - if (AREA_LINE_RECORDS == sscanf(area_str,"A _CODE_%3d size %4x flags %*4x addr %*4x", + // Only match areas which are banked ("_CODE_" vs "_CODE") and ("_LIT_") + if (AREA_LINE_RECORDS == sscanf(area_str,"A _CODE _%3d size %4x flags %*4x addr %*4x", &newarea.bank_num_in, &newarea.size)) { + newarea.type = BANK_TYPE_DEFAULT; + } + else if (AREA_LINE_RECORDS == sscanf(area_str,"A _LIT_%3d size %4x flags %*4x addr %*4x", + &newarea.bank_num_in, &newarea.size)) { + newarea.type = BANK_TYPE_LIT_EXCLUSIVE; + } + else + return false; - // Only process areas with (size > 0) - if (newarea.size > 0) { + // Only process areas with (size > 0) + if (newarea.size > 0) { + if (newarea.type == BANK_TYPE_LIT_EXCLUSIVE) + sprintf(newarea.name, "_LIT_"); // Hardwired to _LIT_ for now + else sprintf(newarea.name, "_CODE_"); // Hardwired to _CODE_ for now - newarea.file_id = file_id; - newarea.bank_num_out = BANK_NUM_UNASSIGNED; - list_additem(&arealist, &newarea); - return true; - } - } - return false; + newarea.file_id = file_id; + newarea.bank_num_out = BANK_NUM_UNASSIGNED; + list_additem(&arealist, &newarea); + return true; + } else + return false; } @@ -315,9 +347,12 @@ static void bank_update_all_max(uint16_t bank_num) { // It should only error out when there isn't enough // room with a fixed-bank area (non-autobank) static void bank_add_area(bank_item * p_bank, uint16_t bank_num, area_item * p_area) { + // Make sure there is room, then update free space and assign outbound bank number + // Copy type from area - some platforms (sms) don't allow mixing of area types in the same bank if (p_area->size <= p_bank->free) { p_bank->free -= p_area->size; + p_bank->type = p_area->type; p_area->bank_num_out = bank_num; bank_update_assigned_minmax(bank_num); } else { @@ -348,12 +383,39 @@ static void bank_check_area_size(area_item * p_area) { } +// Display a error message about bank mixing +static void bank_report_mixed_area_error(bank_item * p_bank, uint16_t bank_num, area_item * p_area) { + + printf("BankPack: ERROR! Bank %d already assigned different area type.\n" + " Can't mix _CODE_ and _LIT_ areas in the same bank for this platform.\n" + " Area %s, bank %d, file:%s\n", + p_area->bank_num_in, p_area->name, bank_num, file_get_name_in_by_id(p_area->file_id)); + + if (g_option_verbose) + banks_show(); +} + + +// Checks whether mixing area types in the same bankshould be rejected +static bool bank_check_mixed_area_types_ok(bank_item * p_bank, uint16_t bank_num, area_item * p_area) { + + // Don't allow mixing of _CODE_ and _LIT_ for sms/gg ports + // If one type has already been assigned to the bank, lock others out + if ((g_platform == PLATFORM_SMS) && + (p_bank->type != BANK_TYPE_UNSET) && + (p_area->type != p_bank->type)) + return false; + else + return true; +} + + // Find an bank for a given area using First Fit Decreasing (FFD) // All possible banks (0-255) were pre-created and initialized [in obj_data_init()], // so there is no need to add when using a fresh bank static void banks_assign_area(area_item * p_area) { - uint16_t c; + uint16_t bank_num; bank_item * banks = (bank_item *)banklist.p_array; bank_check_area_size(p_area); @@ -361,31 +423,43 @@ static void banks_assign_area(area_item * p_area) { // Try to assign fixed bank areas to their expected bank. // (ignore the area if it's outside the processing range) if (p_area->bank_num_in != BANK_NUM_AUTO) { + + bank_num = p_area->bank_num_in; + // Update max bank var that tracks regardless of limits // For auto banks this will get updated via bank_add_area() - bank_update_all_max(p_area->bank_num_in); + bank_update_all_max(bank_num); + + if ((bank_num >= bank_limit_rom_min) && + (bank_num <= bank_limit_rom_max)) { - if ((p_area->bank_num_in >= bank_limit_rom_min) && - (p_area->bank_num_in <= bank_limit_rom_max)) { + if ((g_mbc_type == MBC_TYPE_MBC1) && (!bank_check_mbc1_ok(bank_num))) + printf("BankPack: Warning: Area in fixed bank assigned to MBC1 excluded bank: %d, file: %s\n", bank_num, file_get_name_in_by_id(p_area->file_id)); - if ((g_mbc_type == MBC_TYPE_MBC1) && (!bank_check_mbc1_ok(p_area->bank_num_in))) - printf("BankPack: Warning: Area in fixed bank assigned to MBC1 excluded bank: %d, file: %s\n", p_area->bank_num_in, file_get_name_in_by_id(p_area->file_id)); + if (!bank_check_mixed_area_types_ok(&banks[bank_num], bank_num, p_area)) { + bank_report_mixed_area_error(&banks[bank_num], bank_num, p_area); + exit(EXIT_FAILURE); + } - bank_add_area(&banks[p_area->bank_num_in], p_area->bank_num_in, p_area); + bank_add_area(&banks[bank_num], bank_num, p_area); } else - printf("BankPack: Warning: Area in fixed bank %d is outside specified range %d - %d, file: %s\n", p_area->bank_num_in, bank_limit_rom_min, bank_limit_rom_max, file_get_name_in_by_id(p_area->file_id)); + printf("BankPack: Warning: Area in fixed bank %d is outside specified range %d - %d, file: %s\n", bank_num, bank_limit_rom_min, bank_limit_rom_max, file_get_name_in_by_id(p_area->file_id)); + return; } else if (p_area->bank_num_in == BANK_NUM_AUTO) { // Try to assign area to first allowed bank with enough free space // Bank array index maps directly to bank numbers, so [2] will be _CODE_2 - for (c = bank_limit_rom_min; c <= bank_limit_rom_max ; c++) { + for (bank_num = bank_limit_rom_min; bank_num <= bank_limit_rom_max ; bank_num++) { // Check for MBC bank restrictions - if ((g_mbc_type != MBC_TYPE_MBC1) || (bank_check_mbc1_ok(c))) { - // If there is enough space in current bank, assign it and reduce free space - if (p_area->size <= banks[c].free) { - bank_add_area(&banks[c], c, p_area); - return; + if ((g_mbc_type != MBC_TYPE_MBC1) || (bank_check_mbc1_ok(bank_num))) { + // Check for allowed area mixing if needed + if (bank_check_mixed_area_types_ok(&banks[bank_num], bank_num, p_area)) { + // If there is enough space in current bank, assign it and reduce free space + if (p_area->size <= banks[bank_num].free) { + bank_add_area(&banks[bank_num], bank_num, p_area); + return; + } } } } @@ -515,6 +589,13 @@ bool area_modify_and_write_to_file(char * strline_in, FILE * out_file, uint16_t fprintf(out_file, "\n"); return true; } + else if (strstr(strline_in, "A _LIT_255")) { + fprintf(out_file, "A _LIT_%d %s", bank_num, strstr(strline_in, "size")); + // Add trailing \n if missing (may be, due to using strtok() to split the string) + if (strline_in[(strlen(strline_in)-1)] != '\n') + fprintf(out_file, "\n"); + return true; + } } return false; } diff --git a/gbdk-support/bankpack/obj_data.h b/gbdk-support/bankpack/obj_data.h @@ -12,10 +12,24 @@ #define SYMBOL_LINE_RECORDS 2 // Name, DefVal #define SYMBOL_REWRITE_RECORDS 2 // Name, DefVal +#define PLATFORM_GB 0 +#define PLATFORM_SMS 1 +#define PLATFORM_DEFAULT PLATFORM_GB + +#define PLATFORM_STR_GB "gb" +#define PLATFORM_STR_AP "ap" // Uses PLATFORM_GB +#define PLATFORM_STR_SMS "sms" +#define PLATFORM_STR_GG "gg" // Uses PLATFORM_SMS + +#define BANK_TYPE_UNSET 0 +#define BANK_TYPE_DEFAULT 1 +#define BANK_TYPE_LIT_EXCLUSIVE 2 + typedef struct bank_item { uint32_t size; uint32_t free; + uint32_t type; } bank_item; @@ -25,6 +39,7 @@ typedef struct area_item { uint32_t size; // uint32_t to avoid mingw sscanf() buffer overflow uint32_t bank_num_in; // uint32_t to avoid mingw sscanf() buffer overflow uint32_t bank_num_out; // uint32_t to avoid mingw sscanf() buffer overflow + uint32_t type; } area_item; typedef struct symbol_item { @@ -39,6 +54,8 @@ typedef struct symbol_match_item { char name[OBJ_NAME_MAX_STR_LEN]; } symbol_match_item; +void banks_set_platform(char * platform_str); +int banks_get_platform(void); int banks_get_mbc_type(void); void banks_set_mbc(int); void banks_set_mbc_by_rom_byte_149(int); diff --git a/gbdk-support/lcc/Makefile b/gbdk-support/lcc/Makefile @@ -14,7 +14,7 @@ CFLAGS += -DBUILDDATE=\"$(BUILDDATE)\" -DBUILDTIME=\"$(BUILDTIME)\" ifdef BINDIR CFLAGS += -DGBDKBINDIR=\"$(BINDIR)\" endif -OBJ = lcc.o gb.o +OBJ = lcc.o gb.o targets.o BIN = lcc all: $(BIN) diff --git a/gbdk-support/lcc/gb.c b/gbdk-support/lcc/gb.c @@ -11,32 +11,24 @@ #endif #include "gb.h" +#include "targets.h" #ifndef GBDKLIBDIR #define GBDKLIBDIR "\\gbdk\\" #endif extern char *progname; +extern char * strsave(const char *); -typedef struct { - const char *port; - const char *plat; - const char *default_plat; - const char *cpp; - const char *include; - const char *com; - const char *as; - const char *bankpack; - const char *ld; - const char *ihxcheck; - const char *mkbin; -} CLASS; +// Set default class as the first entry in classes (Game Boy) +static CLASS *_class = &classes[0]; static struct { const char *name; const char *val; } _tokens[] = { - { "port", "gbz80" }, + // expandable string tokens used in "CLASS" command strings + { "port", "gbz80" }, // if default class is ever changed from Game Boy, this default (and plat) may need to be changed to match { "plat", "gb" }, { "sdccdir", "%bindir%"}, { "cpp", "%sdccdir%sdcpp" }, @@ -50,18 +42,21 @@ static struct { { "comopt", "--noinvariant --noinduction" }, { "commodel", "small" }, { "com", "%sdccdir%sdcc" }, - { "comflag", "-c"}, - { "comdefault", "-mgbz80 --no-std-crt0 --fsigned-char --use-stdout" }, + { "comflag", "-c"}, + { "comdefault", "-m%port% --no-std-crt0 --fsigned-char --use-stdout " + " -D__PORT_%port% -D__TARGET_%plat% "}, /* asdsgb assembler defaults: -p: disable pagination -o: create object file -g: make undef symbols global -n: defer symbol resolving to link time (autobanking relies on this) [requires sdcc 12238+] */ - { "asdefault", "-pogn" }, - { "as", "%sdccdir%sdasgb" }, + { "asdefault", "-pogn -I%libdir%%plat%" }, + { "as_gb", "%sdccdir%sdasgb" }, + { "as_z80", "%sdccdir%sdasz80" }, { "bankpack", "%bindir%bankpack" }, - { "ld", "%sdccdir%sdldgb" }, + { "ld_gb", "%sdccdir%sdldgb" }, + { "ld_z80", "%sdccdir%sdldz80" }, { "libdir", "%prefix%lib/%libmodel%/asxxxx/" }, { "libmodel", "small" }, #ifndef GBDKBINDIR @@ -75,12 +70,10 @@ static struct { { "libs_include", "-k %libdir%%port%/ -l %port%.lib -k %libdir%%plat%/ -l %plat%.lib"} }; -#define NUM_TOKENS (sizeof(_tokens)/sizeof(_tokens[0])) - static char *getTokenVal(const char *key) { int i; - for (i = 0; i < NUM_TOKENS; i++) { + for (i = 0; i < ARRAY_LEN(_tokens); i++) { if (!strcmp(_tokens[i].name, key)) return strdup(_tokens[i].val); } @@ -91,7 +84,7 @@ static char *getTokenVal(const char *key) static void setTokenVal(const char *key, const char *val) { int i; - for (i = 0; i < NUM_TOKENS; i++) { + for (i = 0; i < ARRAY_LEN(_tokens); i++) { if (!strcmp(_tokens[i].name, key)) { _tokens[i].val = strdup(val); return; @@ -100,58 +93,11 @@ static void setTokenVal(const char *key, const char *val) assert(0); } -/* -$1 are extra parameters passed using -W -$2 is the list of objects passed as parameters -$3 is the output file -*/ -static CLASS classes[] = { - { "gbz80", - "gb", - "gb", - "%cpp% %cppdefault% -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 $2 $3", - "%includedefault%", - "%com% %comdefault% -Wa%asdefault% -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 %comflag% $2 -o $3", - "%as% %asdefault% $1 $3 $2", - "%bankpack% $1 $2", - "%ld% -n -i $1 %libs_include% $3 %crt0dir% $2", - "%ihxcheck% $2 $1", - "%mkbin% -Z $1 $2 $3" - }, - { "z80", - "afghan", - "afghan", - "%cpp% %cppdefault% $1 $2 $3", - "%includedefault%", - "%com% %comdefault% $1 $2 $3", - "%as% %asdefault% $1 $3 $2", - "%bankpack% $1 $2", - "%ld% -n -- -i $1 -b_CODE=0x8100 %libs_include% $3 %crt0dir% $2", - "%ihxcheck% $2 $1", - "%mkbin% -Z $1 $2 $3" - }, - { "z80", - NULL, - "consolez80", - "%cpp% %cppdefault% $1 $2 $3", - "-I%includedir%/gbdk-lib", - "%com% %comdefault% $1 $2 $3", - "%as% %asdefault% $1 $3 $2", - "%bankpack% $1 $2", - "%ld% -n -- -i $1 -b_DATA=0x8000 -b_CODE=0x200 %libs_include% $3 %crt0dir% $2", - "%ihxcheck% $2 $1", - "%mkbin% -Z $1 $2 $3" - } -}; - -static CLASS *_class = &classes[0]; - -#define NUM_CLASSES (sizeof(classes)/sizeof(classes[0])) - +// Sets the local _class to a given Port/Platform from classes[] static int setClass(const char *port, const char *plat) { int i; - for (i = 0; i < NUM_CLASSES; i++) { + for (i = 0; i < classes_count; i++) { if (!strcmp(classes[i].port, port)) { if (plat && classes[i].plat && !strcmp(classes[i].plat, plat)) { _class = classes + i; @@ -263,6 +209,10 @@ char *ihxcheck[256]; char *ld[256]; char *bankpack[256]; char *mkbin[256]; +char *rom_extension; +arg_entry *llist0_defaults; +int llist0_defaults_len = 0; + const char *starts_with(const char *s1, const char *s2) { @@ -306,18 +256,30 @@ int option(char *arg) { setTokenVal("libs_include", ""); } else if ((tail = starts_with(arg, "-m"))) { - /* Split it up into a asm/port pair */ - char *slash = strchr(tail, '/'); - if (slash) { - *slash++ = '\0'; - setTokenVal("plat", slash); + char word_count = 0; + char * p_str = strtok( strsave(tail),":"); // Copy arg str so it doesn't get unmodified by strtok() + char * words[3]; // +1 in size of expected number of entries to detect excess + + // Split string into words separated by ':' chars (expecting PORT and PLAT) + while (p_str != NULL) { + words[word_count++] = p_str; + p_str = strtok(NULL, ":"); + if (word_count >= ARRAY_LEN(words)) break; } - setTokenVal("port", tail); - if (!setClass(tail, slash)) { - *(slash - 1) = '/'; - fprintf(stderr, "%s: unrecognised port/platform from %s\n", progname, arg); + + // Requires both PORT and PLAT, must match a valid setClass entry. + if (word_count == 2) { + setTokenVal("port", words[0]); + setTokenVal("plat", words[1]); + if (!setClass(words[0], words[1])) { + fprintf(stderr, "Error: %s: unrecognised PORT:PLATFORM from %s:%s\n", progname, words[0], words[1]); + exit(-1); + } + } else { + fprintf(stderr, "Error: -m requires both/only PORT and PLATFORM values (ex: -mgbz80:gb) : %s\n", arg); exit(-1); } + return 1; } else if ((tail = starts_with(arg, "--model-"))) { @@ -337,6 +299,8 @@ int option(char *arg) { return 0; } +// Build the port/platform specific toolchain command strings +// and apply any related settings void finalise(void) { if (!_class->plat) { @@ -350,6 +314,9 @@ void finalise(void) buildArgs(ld, _class->ld); buildArgs(ihxcheck, _class->ihxcheck); buildArgs(mkbin, _class->mkbin); + rom_extension = strdup(_class->rom_extension); + llist0_defaults = _class->llist0_defaults; + llist0_defaults_len = _class->llist0_defaults_len; } void set_gbdk_dir(char* argv_0) diff --git a/gbdk-support/lcc/gb.h b/gbdk-support/lcc/gb.h @@ -13,6 +13,11 @@ #define EXT_OBJ ".obj" #define EXT_IHX ".ihx" #define EXT_GB ".gb" +#define EXT_AP ".pocket" +#define EXT_SMS ".sms" +#define EXT_GG ".gg" + +#define ARRAY_LEN(A) (sizeof(A) / sizeof(A[0])) #endif // _LCC_GB_H diff --git a/gbdk-support/lcc/lcc.c b/gbdk-support/lcc/lcc.c @@ -7,6 +7,7 @@ static char rcsid[] = "$Id: lcc.c,v 2.0 " BUILDDATE " " BUILDTIME " gbdk-2020 Ex #include <stdio.h> #include <stdarg.h> #include <stdlib.h> +#include <stdbool.h> #include <string.h> #include <assert.h> #include <ctype.h> @@ -22,6 +23,7 @@ static char rcsid[] = "$Id: lcc.c,v 2.0 " BUILDDATE " " BUILDTIME " gbdk-2020 Ex #endif #include "gb.h" +#include "targets.h" #ifndef TEMPDIR #define TEMPDIR "/tmp" @@ -58,11 +60,18 @@ extern char *stringf(const char *, ...); extern int suffix(char *, char *[], int); extern char *tempname(char *); +static bool arg_has_searchkey(char *, char *); + +// Adds linker default required vars if not present (defined by user) static void Fixllist(); static void list_rewrite_exts(List, char *, char *); static void list_duplicate_to_new_exts(List, char *, char *); -extern char *cpp[], *include[], *com[], *as[], *bankpack[], *ld[], *ihxcheck[], *mkbin[], inputs[], *suffixes[]; +// These get populated from _class using finalise() in gb.c +extern char *cpp[], *include[], *com[], *as[], *bankpack[], *ld[], *ihxcheck[], *mkbin[], inputs[], *suffixes[], *rom_extension; +extern arg_entry *llist0_defaults; +extern int llist0_defaults_len; + extern int option(char *); extern void set_gbdk_dir(char*); @@ -185,7 +194,11 @@ int main(int argc, char *argv[]) { // Add includes argv[j] = 0; + + // This copies settings from port:platform "class" structure + // into command strings used for compose() finalise(); + for (i = 0; include[i]; i++) clist = append(include[i], clist); if (ilist) { @@ -218,37 +231,30 @@ int main(int argc, char *argv[]) { // Perform Link / ihxcheck / makebin stages (unless some conditions prevent it) - if (errcnt == 0 && !Eflag && !cflag && !Sflag && + if (errcnt == 0 && !Eflag && !cflag && !Sflag && (llist[1] || ((ihxFile[0] != '\0') && ihx_inputs))) { int target_is_ihx = 0; - // If an .ihx file is persent as input, only convert that - // and skip link related stages + // if outfile is not specified, set it to default rom extension for active port:platform + if(!outfile) + outfile = concat("a", rom_extension); + + // If an .ihx file is present as input skip link related stages if (ihx_inputs > 0) { // Only one .ihx can be used for input, warn that others will be ignored if (ihx_inputs > 1) fprintf(stderr, "%s: Warning: Multiple (%d) .ihx files present as input, only one (%s) will be used\n", progname, ihx_inputs, ihxFile); - - // if outfile is not specified, set it to "a.gb" - if(!outfile) - outfile = concat("a", EXT_GB); } else { - // if outfile is not specified, set it to "a.ihx" - if(!outfile) - outfile = concat("a", EXT_IHX); //file.gb to file.ihx (don't use tmpfile because maps and other stuffs are created there) - // Check to see if output is a .ihx file + // Check to see if output target is a .ihx file target_is_ihx = (suffix(outfile, (char *[]){EXT_IHX}, 1) != SUFX_NOMATCH); // Build ihx file name from output name - int lastP = strrchr(outfile, '.') - outfile; - strncpy(ihxFile, outfile, lastP); - ihxFile[lastP] = '\0'; - strcat(ihxFile, ".ihx"); + sprintf(ihxFile, "%s%s", path_stripext(outfile), EXT_IHX); // Only remove .ihx from the delete-list if it's not the final target if (!target_is_ihx) @@ -256,7 +262,12 @@ int main(int argc, char *argv[]) { // if auto bank assignment is enabled, modify obj files before linking if (autobankflag) { - compose(bankpack, bankpack_flags, llist[1], 0); + + // bankpack will be populated if supported by active port:platform + if (bankpack[0][0] != '\0') + compose(bankpack, bankpack_flags, llist[1], 0); + else + fprintf(stderr, "Warning: bankpack enabled but not supported by active port:platform\n"); if (callsys(av)) { errcnt++; @@ -272,9 +283,9 @@ int main(int argc, char *argv[]) { } } } - + // Call linker (add output ihxfile in compose $3) - Fixllist(); // (fixlist adds required default linker vars if not added by user) + Fixllist(); // Fixlist adds required default linker vars if not added by user compose(ld, llist[0], llist[1], append(ihxFile, 0)); if (callsys(av)) @@ -288,7 +299,7 @@ int main(int argc, char *argv[]) { errcnt++; } - // No need to makebin (.ihx -> .gb) if .ihx is final target + // No need to makebin (.ihx -> .gb [or other rom_extension]) if .ihx is final target if (!target_is_ihx) { if(errcnt == 0) @@ -304,22 +315,32 @@ int main(int argc, char *argv[]) { return errcnt ? EXIT_FAILURE : EXIT_SUCCESS; } -/* Adds linker default needed vars if not defined by user */ + + +// Check whether string "arg" has "searchkey" at the first possible +// occurrence of searchkey's starting character in arg (typically "." or "_") +static bool arg_has_searchkey(char * arg, char * searchkey) { + char * str_start = strchr(arg, searchkey[0]); + + if (str_start) + return (strncmp(str_start, searchkey, strlen(searchkey)) == 0); + else + return false; +} + + +// Adds linker default required vars if not present (defined by user) +// Uses data from targets.c for per port/platform defaults static void Fixllist() { - #define BEGINS_WITH(A, B) (A ? strncmp(A, B, sizeof(B) - 1) == 0 : 0) - //-g .OAM=0xC000 -g .STACK=0xE000 -g .refresh_OAM=0xFF80 -b _DATA=0xc0a0 -b _CODE=0x0200 - - int oamDefFound = 0; - int stackDefFound = 0; - int refreshOAMDefFound = 0; - int dataDefFound = 0; - int codeDefFound = 0; + int c; + // Iterate through linker list entries if(llist[0]) { List b = llist[0]; do { b = b->link; + // Only -g and -b settings are supported at this time if(b->str[1] == 'g' || b->str[1] == 'b') { // '-g' and '-b' now have their values separated by a space. @@ -331,42 +352,25 @@ static void Fixllist() else break; // end of list - if(BEGINS_WITH(strchr(b->str, '_'), "_shadow_OAM=")) - oamDefFound = 1; - else if(BEGINS_WITH(strchr(b->str, '.'), ".STACK=")) - stackDefFound = 1; - else if(BEGINS_WITH(strchr(b->str, '.'), ".refresh_OAM=")) - refreshOAMDefFound = 1; - else if(BEGINS_WITH(strchr(b->str, '_'), "_DATA=")) - dataDefFound = 1; - else if(BEGINS_WITH(strchr(b->str, '_'), "_CODE=")) - codeDefFound = 1; + // Check current linker arg to see if any default settings are present + // If they do, flag them as present so they don't need to be added later + for (c = 0; c < llist0_defaults_len; c++) + if (arg_has_searchkey(b->str, llist0_defaults[c].searchkey)) + llist0_defaults[c].found = true; } } while (b != llist[0]); } - if(!oamDefFound) { - llist[0] = append("-g", llist[0]); - llist[0] = append("_shadow_OAM=0xC000", llist[0]); - } - if(!stackDefFound){ - llist[0] = append("-g", llist[0]); - llist[0] = append(".STACK=0xE000", llist[0]); - } - if(!refreshOAMDefFound) { - llist[0] = append("-g", llist[0]); - llist[0] = append(".refresh_OAM=0xFF80", llist[0]); - } - if(!dataDefFound) { - llist[0] = append("-b", llist[0]); - llist[0] = append("_DATA=0xc0a0", llist[0]); - } - if(!codeDefFound) { - llist[0] = append("-b", llist[0]); - llist[0] = append("_CODE=0x0200", llist[0]); - } + // Add required default settings to the linker list if they weren't found + for (c = 0; c < llist0_defaults_len; c++) + if (llist0_defaults[c].found == false) { + // Add the entry to the linker llist[0], flag first then value + llist[0] = append(llist0_defaults[c].addflag, llist[0]); + llist[0] = append(llist0_defaults[c].addvalue, llist[0]); + } } + /* alloc - allocate n bytes or die */ static void *alloc(int n) { static char *avail, *limit; @@ -412,7 +416,7 @@ char *basepath(char *name) { return s; } -// path_stripext - return path with extension removed, +// path_stripext - return a new string of path [name] with extension removed, // e.g. /usr/drh/foo.c => /usr/drh/foo char *path_stripext(char *name) { char * copy_str = strsave(name); @@ -784,6 +788,7 @@ static void help(void) { "-Idir add `dir' to the beginning of the list of #include directories\n", "-K don't run ihxcheck test on linker ihx output\n", "-lx search library `x'\n", +"-m select port and platform: \"-m[port]:[plat]\" ports:mgbz80,z80 plats:ap,gb,sms,gg\n", "-N do not search the standard directories for #include files\n", "-n emit code to check for dereferencing zero pointers\n", "-no-crt do not auto-include the gbdk crt0.o runtime in linker list\n", @@ -902,16 +907,16 @@ static void opt(char *arg) { if(arg[4] == 'y' && (arg[5] == 't' || arg[5] == 'o' || arg[5] == 'a' || arg[5] == 'p') && (arg[6] != '\0' && arg[6] != ' ')) goto makebinoption; //automatically pass -yo -ya -yt -yp options to makebin (backwards compatibility) { - // If using linker file for sdldgb (-f file[.lk]). - // Starting at arg[5] should be name of the linkerfile + // If using linker file for sdldgb (-f file[.lk]). + // Starting at arg[5] should be name of the linkerfile if ((arg[4] == 'f') && (arg[5])) { - llist[1] = append("-f", llist[1]); // Add -f to file link list + llist[1] = append("-f", llist[1]); // Add -f to file link list llist[1] = append(&arg[5], llist[1]); // Then add linkerfile as the very next parameter } else { char *tmp = malloc(256); sprintf(tmp, "%c%c", arg[3], arg[4]); //sdldgb requires spaces between -k and the path llist[0] = append(tmp, llist[0]); //splitting the args into 2 works on Win and Linux - if (arg[5]) { + if (arg[5]) { llist[0] = append(&arg[5], llist[0]); // Add filename separately if present } } @@ -987,7 +992,7 @@ static void opt(char *arg) { if (strcmp(arg, "-no-crt") == 0) { option(arg); // Clear crt0 entry in linker compose string return; - } + } else if (strcmp(arg, "-no-libs") == 0) { option(arg); // Clear libs entry in linker compose string return; diff --git a/gbdk-support/lcc/targets.c b/gbdk-support/lcc/targets.c @@ -0,0 +1,100 @@ +// targets.c + +#include "gb.h" +#include "targets.h" + +// Default Linker list arguments +// +// These get processed in Fixllist() +// +// NOTE: Only -g and -b entries are supported by Fixllist() right now + +// Game Boy / AP +arg_entry llist0_defaults_gb[] = { + {.searchkey= "_shadow_OAM=", .addflag= "-g",.addvalue= "_shadow_OAM=0xC000", .found= false}, + {.searchkey= ".STACK=", .addflag= "-g",.addvalue= ".STACK=0xE000", .found= false}, + {.searchkey= ".refresh_OAM=",.addflag= "-g",.addvalue= ".refresh_OAM=0xFF80",.found= false}, + {.searchkey= "_DATA=", .addflag= "-b",.addvalue= "_DATA=0xC0A0", .found= false}, + {.searchkey= "_CODE=", .addflag= "-b",.addvalue= "_CODE=0x0200", .found= false}, +}; + +// SMS / GG +arg_entry llist0_defaults_sms[] = { + {.searchkey= "_shadow_OAM=", .addflag= "-g",.addvalue= "_shadow_OAM=0xC000", .found= false}, + {.searchkey= ".STACK=", .addflag= "-g",.addvalue= ".STACK=0xDFF0", .found= false}, + {.searchkey= "_DATA=", .addflag= "-b",.addvalue= "_DATA=0xC0C0", .found= false}, + {.searchkey= "_CODE=", .addflag= "-b",.addvalue= "_CODE=0x0200", .found= false}, +}; + + +// Port/Platform specific settings +// +// $1 are extra parameters passed using -W +// $2 is the list of objects passed as parameters +// $3 is the output file +CLASS classes[] = { + // GB + { "gbz80", // port + "gb", // plat + "gb", // default_plat + EXT_GB, // ROM file extension + "%cpp% %cppdefault% -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 $2 $3", + "%includedefault%", + "%com% %comdefault% -Wa%asdefault% -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 %comflag% $2 -o $3", + "%as_gb% %asdefault% $1 $3 $2", + "%bankpack% $1 $2", + "%ld_gb% -n -i $1 %libs_include% $3 %crt0dir% $2", + "%ihxcheck% $2 $1", + "%mkbin% -Z $1 $2 $3", + llist0_defaults_gb, ARRAY_LEN(llist0_defaults_gb), + }, + // AP + { "gbz80", // port + "ap", // plat + "ap", // default_plat + EXT_AP, // ROM file extension + "%cpp% %cppdefault% -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 $2 $3", + "%includedefault%", + "%com% %comdefault% -Wa%asdefault% -DGB=1 -DGAMEBOY=1 -DINT_16_BITS $1 %comflag% $2 -o $3", + "%as_gb% %asdefault% $1 $3 $2", + "%bankpack% $1 $2", + "%ld_gb% -n -i $1 %libs_include% $3 %crt0dir% $2", + "%ihxcheck% $2 $1", + "%mkbin% -Z $1 $2 $3", + llist0_defaults_gb, ARRAY_LEN(llist0_defaults_gb), // Use GB linker list defaults + }, + + // SMS + { "z80", // port + "sms", // plat + "sms", // default_plat + EXT_SMS, // ROM file extension + "%cpp% %cppdefault% -DINT_16_BITS $1 $2 $3", + "%includedefault%", + "%com% %comdefault% -Wa%asdefault% -DINT_16_BITS $1 %comflag% $2 -o $3", + "%as_z80% %asdefault% $1 $3 $2", + "%bankpack% -plat=sms $1 $2", + "%ld_z80% -a sms -n -i $1 %libs_include% $3 %crt0dir% $2", + "%ihxcheck% $2 $1", + "%mkbin% -S $1 $2 $3", + llist0_defaults_sms, ARRAY_LEN(llist0_defaults_sms), + }, + // GG + { "z80", // port + "gg", // plat + "gg", // default_plat + EXT_GG, // ROM file extension + "%cpp% %cppdefault% -DINT_16_BITS $1 $2 $3", + "%includedefault%", + "%com% %comdefault% -Wa%asdefault% -DINT_16_BITS $1 %comflag% $2 -o $3", + "%as_z80% %asdefault% $1 $3 $2", + "%bankpack% -plat=sms $1 $2", + "%ld_z80% -a sms -n -i $1 %libs_include% $3 %crt0dir% $2", + "%ihxcheck% $2 $1", + "%mkbin% -S $1 $2 $3", + llist0_defaults_sms, ARRAY_LEN(llist0_defaults_sms), // Use SMS linker list defaults + } +}; + +int classes_count = ARRAY_LEN(classes); + diff --git a/gbdk-support/lcc/targets.h b/gbdk-support/lcc/targets.h @@ -0,0 +1,38 @@ +// targets.h + +#include <stdbool.h> + +#ifndef _LCC_TARGETS_H +#define _LCC_TARGETS_H + +// For Linker list defaults (llist0) +typedef struct arg_entry { + char searchkey[255]; + char addflag[255]; + char addvalue[255]; + bool found; +} arg_entry; + +// For Port/Platform specific settings +typedef struct CLASS { + const char *port; + const char *plat; + const char *default_plat; + const char *rom_extension; + const char *cpp; + const char *include; + const char *com; + const char *as; + const char *bankpack; + const char *ld; + const char *ihxcheck; + const char *mkbin; + arg_entry *llist0_defaults; + int llist0_defaults_len; +} CLASS; + + +extern CLASS classes[]; +extern int classes_count; + +#endif // _TARGETS_H

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.