jalmah.x68: Commentary (nw)

This commit is contained in:
angelosa 2018-06-17 03:20:03 +02:00
parent a845a6c4fa
commit e4e7a4780c

View File

@ -14,64 +14,61 @@
START: START:
ORG $0 ; palette code snippet (test mode & gameplay) ORG $0 ; palette code snippet (test mode & gameplay)
move.w #$1, $80016.l ; set priority number (for urashima) move.w #$1, $80016.l ; set priority number (for urashima)
move.w #$f, D0 move.w #$f, D0 ; set loop 1
FetchNewPalette: FetchNewPalette:
move.l A0, $100400.l move.l A0, $100400.l ; save address to our local buffer (address currently points to an index of actual palette to transfer)
movea.l (A0), A0 movea.l (A0), A0 ; read ROM location for the actual palette source
move.w #$f, D1 move.w #$f, D1 ; set loop 2 variable
bsr UploadPaletteChunk bsr UploadPaletteChunk ; jump to uploading routine
movea.l $100400.l, A0 movea.l $100400.l, A0 ; restore address index, increment by next address
adda.w #$4, A0 adda.w #$4, A0
dbra D0, FetchNewPalette dbra D0, FetchNewPalette
rts rts
UploadPaletteChunk: UploadPaletteChunk:
move.w (A0)+, (A1)+ move.w (A0)+, (A1)+ ; copy palette source in ROM to palette RAM
dbra D1, UploadPaletteChunk dbra D1, UploadPaletteChunk
rts rts
ORG $0800 ; sound code snippet ORG $0800 ; sound code snippet
; move.w #$0, $8001a.l movem.l D1, -(A7)
; move.w $f0b80.l, $80018.l move.w D0, D1 ; D0 is raw sound command, low byte is command number, everything else is banking and probably voice channel (unhandled)
; move.w $100ffc.l, $80018.l ror.w #$8, D1
; move.w $100ffe.l, $8001a.l and.w #$f, D1 ; take D1 as raw banking number
movem.l D1, -(A7)
move.w D0, D1
ror.w #$8, D1
and.w #$f, D1
bsr CheckSoundZA bsr CheckSoundZA
bsr CheckSoundBank bsr CheckSoundBank
move.w #$8, $80040.l move.w #$8, $80040.l ; clear channel
bsr SoundStatus bsr SoundStatus
andi.w #$3f, D0 andi.w #$3f, D0 ; take command number and write it to OKI port
ori.w #$80, D0 ori.w #$80, D0
move.w D0, $80040.l move.w D0, $80040.l
bsr SoundStatus bsr SoundStatus
move.w #$10, $80040.l move.w #$10, $80040.l ; play channel
movem.l (A7)+, D1 movem.l (A7)+, D1
rts rts
SoundStatus: SoundStatus:
movem.l D0, -(A7) movem.l D0, -(A7)
ReadStatus: ReadStatus:
move.w $80040.l, D0 move.w $80040.l, D0 ; check OKI voice status
andi.w #$1,D0 andi.w #$1,D0
bne ReadStatus bne ReadStatus
movem.l (A7)+, D0 movem.l (A7)+, D0
rts rts
; guess: special bits set in register D0 affect banking (oki can play up to 64 samples so bits 6 and 7 cannot be used) ; guess: special bits set in register D0 affect banking (oki can play up to 64 samples so bits 6 and 7 cannot be used)
; we simulate "ZA" writing but use the other bank register (jalmah can do both, cfr. ports $80018 and $8001a
CheckSoundZA: CheckSoundZA:
btst #$6, D0 ;urashima BGM at start of game btst #$6, D0 ; urashima BGM at start of game
beq NoZA1 beq NoZA1
ror.w #$1, D1 ror.w #$1, D1 ; shift one down
rts rts
NoZA1: NoZA1:
btst #$07, D0 ;mjzoomin BGM at start of game btst #$07, D0 ; mjzoomin BGM at start of game
beq NoZA2 beq NoZA2
move.w #$8, D1 move.w #$8, D1 ; hardcode to bank 3
NoZA2: NoZA2:
rts rts
CheckSoundBank: CheckSoundBank:
cmpi.w #$1, D1 cmpi.w #$1, D1 ; verify our raw D1 and set base bank accordingly
beq SetBank0 beq SetBank0
cmpi.w #$2, D1 cmpi.w #$2, D1
beq SetBank1 beq SetBank1
@ -91,29 +88,29 @@ SetBank2:
ORG $1000 ; tile upload snippet ORG $1000 ; tile upload snippet
TileUploadStart: TileUploadStart:
move.w (A2)+, (A1)+ move.w (A2)+, (A1)+ ; just take A2 source (tiles) to A1 destination VRAM
dbra D0, TileUploadStart dbra D0, TileUploadStart
rts rts
ORG $1800 ; (another) palette code snippet ORG $1800 ; (another) palette code snippet
movem.l D0-D7/A1-A6, -(A7) ; save stack (A0 intentionally updated by this snippet) movem.l D0-D7/A1-A6, -(A7) ; save stack (A0 intentionally updated by this snippet)
move.w #$f, D0 move.w #$f, D0 ; what's the difference here? Same as above but no hardcoded priority?
bsr FetchNewPalette bsr FetchNewPalette
movem.l (A7)+, D0-D7/A1-A6 movem.l (A7)+, D0-D7/A1-A6
rts rts
ORG $2000 ; daireikai RNG snippet (guess) ORG $2000 ; daireikai RNG snippet (guess)
move.w D5, $100400.l move.w D5, $100400.l
move.w $f000c.l, D5 move.w $f000c.l, D5 ; take current RNG number
add.l D6, D5 add.l D6, D5 ; add D6
andi.w #$3f, D5 andi.w #$3f, D5
move.w D5, $f000c.l move.w D5, $f000c.l ; round it
move.w $100400.l, D5 move.w $100400.l, D5
rts rts
ORG $2800 ; daireikai layer clearances ORG $2800 ; daireikai layer clearances
movem.l D0-D7/A0-A6, -(A7) movem.l D0-D7/A0-A6, -(A7)
lea $90000.l, A6 lea $90000.l, A6 ; layer 0
move.w #$1fff, D1 move.w #$1fff, D1
move.w #$00ff, D0 move.w #$00ff, D0
bsr ClearLayer bsr ClearLayer
movem.l (A7)+, D0-D7/A0-A6 movem.l (A7)+, D0-D7/A0-A6
@ -124,7 +121,7 @@ ClearLayer:
rts rts
ORG $2880 ORG $2880
movem.l D0-D7/A0-A6, -(A7) movem.l D0-D7/A0-A6, -(A7)
lea $94000.l, A6 lea $94000.l, A6 ; layer 1
move.w #$1fff, D1 move.w #$1fff, D1
move.w #$00ff, D0 move.w #$00ff, D0
bsr ClearLayer bsr ClearLayer
@ -132,7 +129,7 @@ ClearLayer:
rts rts
ORG $2900 ORG $2900
movem.l D0-D7/A0-A6, -(A7) movem.l D0-D7/A0-A6, -(A7)
lea $98000.l, A6 lea $98000.l, A6 ; layer 2
move.w #$1fff, D1 move.w #$1fff, D1
move.w #$f0ff, D0 move.w #$f0ff, D0
bsr ClearLayer bsr ClearLayer
@ -143,6 +140,7 @@ ClearLayer:
dc.w $ffff dc.w $ffff
END START END START
*~Font name~Courier New~ *~Font name~Courier New~
*~Font size~10~ *~Font size~10~
*~Tab type~1~ *~Tab type~1~