Sorry guys! Super busy. Here is what I have on my work PC
Known Routines:
$097D - "Delay_1" This is a delay routine, value passed via BC
$03AD - "LCD_Turn_Off" No variables passed
$0462 - "Zero_RAM" Start location passed in HL, number of bytes to zero in BC
$03E2 - "DMA_Routine_2_HRAM" , No Variables, moves a 10 byte program into HRAM, the DMA routine.
$092A - "Init_OAM_Buffer" ;Sets the OAM buffer ($D400) to 0xF0
$0914 - "Clear_Tile_Map0" ;sets $9800-9BFF to $FF
$091F - "Clear_Tile_Map1" ;sets $9C00-9FFF to $FF
$2B25 - "Init_Snd" ;Turns sound registers on, volume, channels, clears DD00-DF00
$1DEC -
$1DE0 - "Delay_2" , No variables Passed.
Known Memory Locations:
$FF9B - Current Memory Bank selected
$D400 - D49F - DMA Start address (Buffer?)
$DD00-DF00 - Suspected Sound buffers?
$0101: Jp Main
Main:
Ld sp, $FFFE ;Initialise Stack
Di ;disable interrupts
Xor a ;clear a
Ldh [$FF0F], a ;Dissable all IRQ’s
Ldh a,[$FF40] ;Get LCDC
Bit 7,a ;Test bit 7 – Display Enabled?
Jr zn, LCD_Enabled ;Conditional Jump ()
Set 7,a ;set bit 7
Ldh [$FF40],a ;Store LCDC
LCD_Enabled:
Ld bc, $0002 ;pass $0002 to Function $097D
Call Delay_1 ;Jazz, Please watch this in the emulator to find the delay length?
;Best guess is the delay is necessary to initialise the cart MCU
VblankWait:
Ldh a,[FF44] ;Waiting for a V-Blank…
Cp a,$91
Jr c,VblankWait
Ld a,$80
Ldh [$FF40],a ;Enable LCD – Did I make a mistake with the above routines? Jazz?
Xor a ;Clear A
Ldh [$FF47],a ;Clear Pallete Data
Ldh [$FF48],a ;Clear Pallete Data
Ldh [$FF49],a ;Clear Pallete Data
Ld bc, $0002 ;pass $0002 to Function $097D
Call Delay_1 ;Jazz, Please watch this in the emulator to find the delay length?
Call Turn_LCD_Off
ld hl,$C000 ;Load HL with Work RAM location
ld BC,$1FFF ;Load BC with 1FFF
Call Zero_RAM ;Zero BC number of bytes, from location HL
ld a,$00 ;Why do they zero A this way, and not XOR A like other routines???
ld [$0000],a ;Disable Cartridge Save RAM
ld a,$01 ;
ld [$2000],a ;Set ROM bank 1
ld a,$00
ld [$4000],a ;Set Ram bank 0
ld a,$01
ldh [$FF9B],a ;Store 1 into FF9B - Perhaps a buffer to keep track of bank numbers?
ld sp,$DFFF ;Move stack pointer to $DFFF
ld hl,$FF80 ;Load $FF80 into HL
ld bc,$007E ;Load $007E into BC
Call Zero_RAM ;Clear the HRAM
Call DMA_Routine_2_HRAM ;move the DMA routine to HRAM
Call Init_OAM_Buffer ;Sets the OAM buffer ($D400) to 0xF0
Call Clear_Tile_Map0
Call Clear_Tile_Map1
xor a ;Clear A
ld [$D520],a ;Zero all these important registers...
ld [$D521],a
ld [$D522],a
ldh [$FFC5],a
ldh [$FFC6],a
ldh [$FFD0],a
ldh [$FFD4],a
ld [$DC41],a
ld [$D523],a
ldh [$FFC4],a
ld hl,$FFAB
xor a
ldi [hl],a ;Zero from FFAB - FFB2
ldi [hl],a
ldi [hl],a
ldi [hl],a
ldi [hl],a
ldi [hl],a
ldi [hl],a
ldi [hl],a
ld a,$8F
ldi [hl],a ;$8F into FFB3
ld a,$A6
ldi [hl], ;$A6 into FFB4
Call Init_Snd ;
Call $1DEC ;
$1DEC:
ld a,$0B
ld hl,$4010
call $1D95
call Delay_2
ldh a,[$FF00]
and a,$03
cp a,$03
jr nz,$1E3A
ld a,$20
ldh [$FF00],a
ldh a,[$FF00]
ldh a,[$FF00]
ld a,$30
ldh [$FF00],a
ld a,$10
ldh [$FF00],a
ldh a,[$FF00]
ldh a,[$FF00]
ldh a,[$FF00]
ldh a,[$FF00]
ldh a,[$FF00]
ldh a,[$FF00]
ld a,$30
ldh [$FF00],a
ldh a,[$FF00]
ldh a,[$FF00]
ldh a,[$FF00]
ldh a,[$FF00]
and a,$03
cp a,$03
jr nz,$1E3A
ld a,$0B
ld hl,$4000
call $1D95
call $1DE0
and a
ret
ld a,$0B
ld hl,$4000
call $1D95
call Delay_2
scf
ret
$1D95: ;Variables passed, A and HL
ldh [$FF9D],a ;put variable A into FF9D - Temp bank buffer 2?
ldh a,[BankBuffer] ;Get current bank
push af ;Store it on the stack
ldh a,[$FF9D] ;Get that variable buffer
ldh [BankBuffer],a ;Update the current bank register
ld [$2000],a ;Set the bank
ld a,[hl] ;Load first byte of passed variable HL
and a,$07 ;cmp with $07
jr z,Label1 ;if something, then end routine.....
ld b,a ;otherwise, multiply it by 0xFF, and put it in BC
ld c,$00
push bc ;push BC onto the stack
ld a,$00
ld [$ff00+c],a ;Clear keypad latch
ld a,$30
ld [$ff00+c],a ;Set P14+15 high
ld b,$10 ;load B with $10
Label4: ld e,$08 ;Load E with $08
ldi a,[hl]
ld d,a
Label3: bit 0,d
ld a,$10
jr nz,Label2
ld a,$20
Label2: ld [$ff00+c],a
ld a,$30
ld [$ff00+c],a
rr d
dec e
jr nz,Label3
dec b
jr nz,Label4
ld a,$20
ld [$ff00+c],a
ld a,$30
ld [$ff00+c],a
pop bc
dec b
jr z,Label1
call Delay_2
jr $1DA9
Label1: pop af
ldh [BankBuffer],a
ld [$2000],a
ret
Delay_2:
ld de,$1B58
.Loop nop
nop
nop
dec de
ld a,d
or e
jr nz,.Loop
ret
Init_Snd: ;Set bank 1F, execute code at $7FF6, Restore previous bank.
ldh a,[$FF9B] ;Store the current ROM bank
push af
ld a,$1F ;Change to ROM Bank 1F
ldh [$FF9B],a ;Update the bank buffer
ld [$2000],a ;Switch bank 1F
call $7FF6 ;Turn on Sound registers, Zero DD00-DF00 - Sound buffers???
pop af ;Restore the current rom bank
ldh [$FF9B],a ;
d [$2000],a ;Set the current rom bank.
ret
1F:7FF6 > jumps to :5343
1F:5343:
ld a,$80
ldh [$FF26],a ;Enable all sound channels
ld a,$77
ldh [$FF24],a ;Max volume
ld a,$FF
ldh [$FF25],a ;Sound output to all terminals
ld hl,$DD00
.Loop ld [hl],$00 ;Zero DD00-DF00
inc l
jr nz,.Loop
inc h
ld a,h
cp a,$DF
jr nz,.Loop
ret
Clear_Tile_Map0:
ld a,$FF
ld hl,$9800
ldi [hl],a
bit 2,h
jr z,$0919
ret
Clear_Tile_Map1:
ld a,$FF
ld hl,$9C00
ldi [hl],a
bit 5,h
jr z,$0924
ret
Init_OAM_Buffer: ;Set OAM buffer to 0xF0, all of it.
ld hl,$D400
ld b,$A0
ld a,$F0
ldi [hl],a
dec b
jr nz,$0931
xor a
ldh [$FF9A],a
ret
DMA_Routine_2_HRAM: ;Move the DMA transfer routine into HRAM
ld c,$80
ld b,$0A
ld hl,DMA_Routine
ldi a,[hl] ;
ld [$ff00+c],a
inc c
dec b
jr nz,$03E9
ret
DMA_Routine: ;This routine is placed into HRAM via DMA_Routine_2_HRAM
ld a,$D4 ;Start address = $D400, Destination is FE00
ldh [$FF46],a
ld a,$28
dec a
jr nz,$03F6
Ret
Zero_RAM:
xor a
ldi [hl],a
dec bc
ld a,c
or b
jr nz,$0462
ret
Turn_LCD_Off:
Ldh a,[$FF40] ; get LCDC
Bit 7,a ;Disabled?
Ret z ;return with zero flag carried
Ldh a,[$FFFF] ;Get Interrupt Status
Push AF ;push it to the stack
And A,$FC ;Clear bits 0+1 – Vblank int, and LCD Stat int.
Ldh [$FFFF],A ;Update the interrupt status
.Wait4V:
Ld a,[FF44]
Cp a,$91
Jr nz, .Wait4V
Ldh a,[$FFAB] ;FFAB is a buffer register of LCDC
Res 7,a
ldh [$FF40],a ;store in LCDC
ldh [$FFAB],a ;Update LCDC buffer register
pop af
ldh [$FFFF],a ;restore the Interupt register
RET
Delay_1 : ;Data passed in via Register BC
Ld de,$06D6 ;Delay loop pre-set
Delay_Inner_Loop:
Nop
Nop
Nop
Dec de ;
Ld a,d ;
Or e ;
Jr nz, Delay_Inner_Loop: ;Loop $06D6 times
Dec BC
Ld a,b
Or c
Jr nz, Delay_1: ;Loop the above loop, BC times.
Ret
There is more on my home PC