git.y1.nz

gbdk-2020

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

commit 9fc175a4d78a0555dd9fa175526d038a384458c2
parent 5719880955a8495c6045bd2ecbec31f9bc166cb9
Author: Toxa <untoxa@mail.ru>
Date:   Tue, 31 Jan 2023 01:47:15 +0300

GB: shuffled stuff in crt0 to free some ROM0 space

Diffstat:
Mgbdk-lib/libc/targets/sm83/ap/crt0.s168+++++++++++++++++++++++++++++++++++++++----------------------------------------
Mgbdk-lib/libc/targets/sm83/ap/global.s54+++++++++++++++++++++++++++---------------------------
Mgbdk-lib/libc/targets/sm83/duck/crt0.s166++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mgbdk-lib/libc/targets/sm83/duck/global.s54+++++++++++++++++++++++++++---------------------------
Mgbdk-lib/libc/targets/sm83/gb/crt0.s168+++++++++++++++++++++++++++++++++++++++----------------------------------------
Mgbdk-lib/libc/targets/sm83/gb/global.s2+-
6 files changed, 304 insertions(+), 308 deletions(-)

diff --git a/gbdk-lib/libc/targets/sm83/ap/crt0.s b/gbdk-lib/libc/targets/sm83/ap/crt0.s @@ -121,9 +121,30 @@ _refresh_OAM:: RST 0x28 RET - ;; GameBoy Header + ;; Wait for VBL interrupt to be finished +.wait_vbl_done:: +_wait_vbl_done:: +_vsync:: + ;; 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 + + .org .MODE_TABLE + ;; Jump table for modes + RET - ;; DO NOT CHANGE... + ;; GameBoy Header .org 0x100 .header: JR .code_start @@ -293,8 +314,66 @@ _set_interrupts:: RET .end_refresh_OAM: - .org .MODE_TABLE - ;; Jump table for modes + ;; Remove interrupt routine in DE from the VBL interrupt list + ;; falldown to .remove_int +_remove_VBL:: +.remove_VBL:: + LD HL,#.int_0x40 + + ;; Remove interrupt DE from interrupt list HL if it exists + ;; Abort if a 0000 is found (end of list) +.remove_int:: +1$: + LD A,(HL+) + LD C,A + LD A,(HL+) + LD B,A + OR C + RET Z ; No interrupt found + + LD A,E + CP C + JR NZ,1$ + LD A,D + CP B + JR NZ,1$ + + LD B,H + LD C,L + DEC BC + DEC BC + + ;; Now do a memcpy from here until the end of the list +2$: + LD A,(HL+) + LD (BC),A + INC BC + LD D,A + LD A,(HL+) + LD (BC),A + INC BC + OR D + JR NZ, 2$ + RET + + ;; Add interrupt routine in BC to the VBL interrupt list + ;; falldown to .add_int +_add_VBL:: +.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,D + LD (HL-),A + LD (HL),E RET ;; **************************************** @@ -407,87 +486,6 @@ gsinit:: 4$: RET - ;; Remove interrupt routine in DE from the VBL interrupt list - ;; falldown to .remove_int -_remove_VBL:: -.remove_VBL:: - LD HL,#.int_0x40 - - ;; Remove interrupt DE from interrupt list HL if it exists - ;; Abort if a 0000 is found (end of list) -.remove_int:: -1$: - LD A,(HL+) - LD C,A - LD A,(HL+) - LD B,A - OR C - RET Z ; No interrupt found - - LD A,E - CP C - JR NZ,1$ - LD A,D - CP B - JR NZ,1$ - - LD B,H - LD C,L - DEC BC - DEC BC - - ;; Now do a memcpy from here until the end of the list -2$: - LD A,(HL+) - LD (BC),A - INC BC - LD D,A - LD A,(HL+) - LD (BC),A - INC BC - OR D - JR NZ, 2$ - RET - - ;; Add interrupt routine in BC to the VBL interrupt list - ;; falldown to .add_int -_add_VBL:: -.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,D - LD (HL-),A - LD (HL),E - RET - - ;; Wait for VBL interrupt to be finished -.wait_vbl_done:: -_wait_vbl_done:: -_vsync:: - ;; 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 diff --git a/gbdk-lib/libc/targets/sm83/ap/global.s b/gbdk-lib/libc/targets/sm83/ap/global.s @@ -21,7 +21,7 @@ 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 @@ -35,7 +35,7 @@ .P14 = 0x10 .P15 = 0x20 - ;; Screen dimensions + ;; Screen dimensions .MAXCURSPOSX = 0x13 ; In tiles .MAXCURSPOSY = 0x11 @@ -47,17 +47,17 @@ .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 @@ -76,7 +76,7 @@ .TMA = 0x06 ; Timer modulo rTMA = 0xFF06 - + .TAC = 0x07 ; Timer control rTAC = 0xFF07 @@ -89,7 +89,7 @@ .IF = 0x0F ; Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL rIF = 0xFF0F - + .NR10 = 0x10 ; Sound register rNR10 = 0xFF10 rAUD1SWEEP = 0xFF10 @@ -104,7 +104,7 @@ .NR12 = 0x12 ; Sound register rNR12 = 0xFF12 rAUD1ENV = 0xFF12 - + .NR13 = 0x13 ; Sound register rNR13 = 0xFF13 rAUD1LOW = 0xFF13 @@ -287,21 +287,21 @@ .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 @@ -312,7 +312,7 @@ .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 @@ -320,18 +320,18 @@ .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 @@ -350,21 +350,21 @@ 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 @@ -413,7 +413,7 @@ ;; CPU detection .DMG_TYPE = 0x01 ; Original GB or Super GB .MGB_TYPE = 0xFF ; Pocket GB or Super GB 2 - .CGB_TYPE = 0x11 ; Color GB + .CGB_TYPE = 0x11 ; Color GB ;; GBDK library screen modes @@ -423,7 +423,7 @@ .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 @@ -435,7 +435,7 @@ .DT_RECEIVING = 0x55 ;; Table of routines for modes - .MODE_TABLE = 0x01E0 + .MODE_TABLE = 0x00F0 ;; C related ;; Overheap of a banked call. Used for parameters @@ -445,7 +445,7 @@ .globl __current_bank .globl __shadow_OAM_base - + ;; Global variables .globl .mode @@ -461,7 +461,7 @@ .globl .wait_vbl_done - ;; Interrupt routines + ;; 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 @@ -473,7 +473,7 @@ .globl _shadow_OAM .globl .refresh_OAM - ;; Main user routine + ;; Main user routine .globl _main ;; Macro definitions diff --git a/gbdk-lib/libc/targets/sm83/duck/crt0.s b/gbdk-lib/libc/targets/sm83/duck/crt0.s @@ -122,6 +122,29 @@ _refresh_OAM:: RST 0x28 RET + ;; Wait for VBL interrupt to be finished +.wait_vbl_done:: +_wait_vbl_done:: +_vsync:: + ;; 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 + + .org .MODE_TABLE + ;; Jump table for modes + RET + .org 0x150 ;; soft reset: falldown to .code_start @@ -233,8 +256,66 @@ _set_interrupts:: RET .end_refresh_OAM: - .org .MODE_TABLE - ;; Jump table for modes + ;; Remove interrupt routine in DE from the VBL interrupt list + ;; falldown to .remove_int +_remove_VBL:: +.remove_VBL:: + LD HL,#.int_0x40 + + ;; Remove interrupt DE from interrupt list HL if it exists + ;; Abort if a 0000 is found (end of list) +.remove_int:: +1$: + LD A,(HL+) + LD C,A + LD A,(HL+) + LD B,A + OR C + RET Z ; No interrupt found + + LD A,E + CP C + JR NZ,1$ + LD A,D + CP B + JR NZ,1$ + + LD B,H + LD C,L + DEC BC + DEC BC + + ;; Now do a memcpy from here until the end of the list +2$: + LD A,(HL+) + LD (BC),A + INC BC + LD D,A + LD A,(HL+) + LD (BC),A + INC BC + OR D + JR NZ, 2$ + RET + + ;; Add interrupt routine in BC to the VBL interrupt list + ;; falldown to .add_int +_add_VBL:: +.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,D + LD (HL-),A + LD (HL),E RET ;; **************************************** @@ -347,87 +428,6 @@ gsinit:: 4$: RET - ;; Remove interrupt routine in DE from the VBL interrupt list - ;; falldown to .remove_int -_remove_VBL:: -.remove_VBL:: - LD HL,#.int_0x40 - - ;; Remove interrupt DE from interrupt list HL if it exists - ;; Abort if a 0000 is found (end of list) -.remove_int:: -1$: - LD A,(HL+) - LD C,A - LD A,(HL+) - LD B,A - OR C - RET Z ; No interrupt found - - LD A,E - CP C - JR NZ,1$ - LD A,D - CP B - JR NZ,1$ - - LD B,H - LD C,L - DEC BC - DEC BC - - ;; Now do a memcpy from here until the end of the list -2$: - LD A,(HL+) - LD (BC),A - INC BC - LD D,A - LD A,(HL+) - LD (BC),A - INC BC - OR D - JR NZ, 2$ - RET - - ;; Add interrupt routine in BC to the VBL interrupt list - ;; falldown to .add_int -_add_VBL:: -.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,D - LD (HL-),A - LD (HL),E - RET - - ;; Wait for VBL interrupt to be finished -.wait_vbl_done:: -_wait_vbl_done:: -_vsync:: - ;; 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 diff --git a/gbdk-lib/libc/targets/sm83/duck/global.s b/gbdk-lib/libc/targets/sm83/duck/global.s @@ -21,7 +21,7 @@ rROMB0 = 0x0001 ; $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 @@ -35,7 +35,7 @@ .P14 = 0x10 .P15 = 0x20 - ;; Screen dimensions + ;; Screen dimensions .MAXCURSPOSX = 0x13 ; In tiles .MAXCURSPOSY = 0x11 @@ -47,17 +47,17 @@ .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 @@ -76,7 +76,7 @@ .TMA = 0x06 ; Timer modulo rTMA = 0xFF06 - + .TAC = 0x07 ; Timer control rTAC = 0xFF07 @@ -89,7 +89,7 @@ .IF = 0x0F ; Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL rIF = 0xFF0F - + .NR10 = 0x20 ; Sound register rNR10 = 0xFF20 rAUD1SWEEP = 0xFF20 @@ -104,7 +104,7 @@ .NR12 = 0x21 ; Sound register rNR12 = 0xFF21 rAUD1ENV = 0xFF21 - + .NR13 = 0x23 ; Sound register rNR13 = 0xFF23 rAUD1LOW = 0xFF23 @@ -287,21 +287,21 @@ .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 @@ -312,7 +312,7 @@ .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 @@ -320,18 +320,18 @@ .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 @@ -350,21 +350,21 @@ 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 @@ -413,7 +413,7 @@ ;; CPU detection .DMG_TYPE = 0x01 ; Original GB or Super GB .MGB_TYPE = 0xFF ; Pocket GB or Super GB 2 - .CGB_TYPE = 0x11 ; Color GB + .CGB_TYPE = 0x11 ; Color GB ;; GBDK library screen modes @@ -423,7 +423,7 @@ .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 @@ -435,7 +435,7 @@ .DT_RECEIVING = 0x55 ;; Table of routines for modes - .MODE_TABLE = 0x01E0 + .MODE_TABLE = 0x00F0 ;; C related ;; Overheap of a banked call. Used for parameters @@ -445,7 +445,7 @@ .globl __current_bank .globl __shadow_OAM_base - + ;; Global variables .globl .mode @@ -461,7 +461,7 @@ .globl .wait_vbl_done - ;; Interrupt routines + ;; 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 @@ -473,7 +473,7 @@ .globl _shadow_OAM .globl .refresh_OAM - ;; Main user routine + ;; Main user routine .globl _main ;; Macro definitions diff --git a/gbdk-lib/libc/targets/sm83/gb/crt0.s b/gbdk-lib/libc/targets/sm83/gb/crt0.s @@ -121,9 +121,30 @@ _refresh_OAM:: RST 0x28 RET - ;; GameBoy Header + ;; Wait for VBL interrupt to be finished +.wait_vbl_done:: +_wait_vbl_done:: +_vsync:: + ;; 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 + + .org .MODE_TABLE + ;; Jump table for modes: 4 modes, 4 bytes each 16 bytes total + RET - ;; DO NOT CHANGE... + ;; GameBoy Header .org 0x100 .header: JR .code_start @@ -299,8 +320,66 @@ _set_interrupts:: RET .end_refresh_OAM: - .org .MODE_TABLE - ;; Jump table for modes + ;; Remove interrupt routine in DE from the VBL interrupt list + ;; falldown to .remove_int +_remove_VBL:: +.remove_VBL:: + LD HL,#.int_0x40 + + ;; Remove interrupt DE from interrupt list HL if it exists + ;; Abort if a 0000 is found (end of list) +.remove_int:: +1$: + LD A,(HL+) + LD C,A + LD A,(HL+) + LD B,A + OR C + RET Z ; No interrupt found + + LD A,E + CP C + JR NZ,1$ + LD A,D + CP B + JR NZ,1$ + + LD B,H + LD C,L + DEC BC + DEC BC + + ;; Now do a memcpy from here until the end of the list +2$: + LD A,(HL+) + LD (BC),A + INC BC + LD D,A + LD A,(HL+) + LD (BC),A + INC BC + OR D + JR NZ, 2$ + RET + + ;; Add interrupt routine in DE to the VBL interrupt list + ;; falldown to .add_int +_add_VBL:: +.add_VBL:: + LD HL,#.int_0x40 + + ;; Add interrupt routine in DE to the interrupt list in HL +.add_int:: +1$: + LD A,(HL+) + OR (HL) + JR Z,2$ + INC HL + JR 1$ +2$: + LD A,D + LD (HL-),A + LD (HL),E RET ;; **************************************** @@ -417,87 +496,6 @@ gsinit:: 4$: RET - ;; Remove interrupt routine in DE from the VBL interrupt list - ;; falldown to .remove_int -_remove_VBL:: -.remove_VBL:: - LD HL,#.int_0x40 - - ;; Remove interrupt DE from interrupt list HL if it exists - ;; Abort if a 0000 is found (end of list) -.remove_int:: -1$: - LD A,(HL+) - LD C,A - LD A,(HL+) - LD B,A - OR C - RET Z ; No interrupt found - - LD A,E - CP C - JR NZ,1$ - LD A,D - CP B - JR NZ,1$ - - LD B,H - LD C,L - DEC BC - DEC BC - - ;; Now do a memcpy from here until the end of the list -2$: - LD A,(HL+) - LD (BC),A - INC BC - LD D,A - LD A,(HL+) - LD (BC),A - INC BC - OR D - JR NZ, 2$ - RET - - ;; Add interrupt routine in DE to the VBL interrupt list - ;; falldown to .add_int -_add_VBL:: -.add_VBL:: - LD HL,#.int_0x40 - - ;; Add interrupt routine in DE to the interrupt list in HL -.add_int:: -1$: - LD A,(HL+) - OR (HL) - JR Z,2$ - INC HL - JR 1$ -2$: - LD A,D - LD (HL-),A - LD (HL),E - RET - - ;; Wait for VBL interrupt to be finished -.wait_vbl_done:: -_wait_vbl_done:: -_vsync:: - ;; 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 diff --git a/gbdk-lib/libc/targets/sm83/gb/global.s b/gbdk-lib/libc/targets/sm83/gb/global.s @@ -435,7 +435,7 @@ .DT_RECEIVING = 0x55 ;; Table of routines for modes - .MODE_TABLE = 0x01E0 + .MODE_TABLE = 0x00F0 ;; C related ;; Overheap of a banked call. Used for parameters

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