AbePralle-FGB/Source/l0203.asm

167 lines
4.3 KiB
NASM
Raw Normal View History

2020-05-31 09:42:40 +01:00
;leveL0203.asm
2020-05-31 04:23:06 +01:00
;Abe Pralle 3.4.2000
INCLUDE "Source/defs.inc"
INCLUDE "Source/levels.inc"
;---------------------------------------------------------------------
2020-05-31 05:07:40 +01:00
SECTION "LevelsSection0203",ROMX
2020-05-31 04:23:06 +01:00
;---------------------------------------------------------------------
L0203_Contents::
DW L0203_Load
DW L0203_Init
DW L0203_Check
DW L0203_Map
;---------------------------------------------------------------------
; landing
;---------------------------------------------------------------------
L0203_Load:
DW ((L0203_LoadFinished - L0203_Load2)) ;size
L0203_Load2:
call ParseMap
2020-05-31 04:46:09 +01:00
ret
2020-05-31 04:23:06 +01:00
L0203_LoadFinished:
L0203_Map:
2020-05-31 09:42:40 +01:00
INCBIN "Data/Levels/L0203_path.lvl"
2020-05-31 04:23:06 +01:00
2020-05-31 09:09:52 +01:00
;gtx_intro: INCBIN "Data/Dialog/Landing/intro.gtx"
;gtx_intro2: INCBIN "Data/Dialog/Landing/intro2.gtx"
;gtx_finished: INCBIN "Data/Dialog/Landing/finished.gtx"
;gtx_finished2: INCBIN "Data/Dialog/Landing/finished2.gtx"
2020-05-31 04:23:06 +01:00
;---------------------------------------------------------------------
L0203_Init:
;---------------------------------------------------------------------
DW ((L0203_InitFinished - L0203_Init2)) ;size
L0203_Init2:
ret
L0203_InitFinished:
;---------------------------------------------------------------------
L0203_Check:
;---------------------------------------------------------------------
DW ((L0203_CheckFinished - L0203_Check) - 2) ;size
L0203_Check2:
2020-05-31 04:46:09 +01:00
;-----------------see what zone the hero is in------------------
;get hero object
ld a,[hero0_object]
ld l,a
ld a,[hero0_object+1]
ld h,a
;get hero's location from hero object
2020-05-31 04:23:06 +01:00
ld a,OBJBANK
2020-05-31 04:46:09 +01:00
ld [$ff70],a
ld e,[hl]
inc hl
ld d,[hl]
2020-05-31 04:23:06 +01:00
;see what zone he's in
2020-05-31 04:46:09 +01:00
ld a,ZONEBANK
ld [$ff70],a
ld a,[de]
and %1111 ;no exit info please
ld [mapHeroZone],a
2020-05-31 04:23:06 +01:00
;change palette if changed zones
2020-05-31 04:46:09 +01:00
ld hl,(.lastZone + (levelCheckRAM-L0203_Check2))
cp [hl]
jr z,.afterChangePalette
2020-05-31 04:23:06 +01:00
;note new zone
2020-05-31 04:46:09 +01:00
ld [(.lastZone + (levelCheckRAM-L0203_Check2))],a
2020-05-31 04:23:06 +01:00
2020-05-31 04:46:09 +01:00
ld a,FADEBANK
ld [$ff70],a
2020-05-31 04:23:06 +01:00
2020-05-31 04:46:09 +01:00
;copy standard palette to fadeFinalPalette, dividing colors by two
ld hl,(.stdPaletteData + (levelCheckRAM-L0203_Check2))
ld de,fadeFinalPalette
ld c,32
2020-05-31 04:23:06 +01:00
.copyLoop
push bc
2020-05-31 04:46:09 +01:00
ld a,[mapHeroZone]
ld c,a
2020-05-31 04:23:06 +01:00
ld a,[hl+] ;low byte
2020-05-31 04:46:09 +01:00
ld b,a
ld a,[hl+] ;high byte
2020-05-31 04:23:06 +01:00
2020-05-31 04:46:09 +01:00
;rotate ab by # bits equal to the current zone number - 1
dec c
jr z,.shiftDone
2020-05-31 04:23:06 +01:00
.shiftLoop
2020-05-31 04:46:09 +01:00
rrca
rr b
2020-05-31 04:23:06 +01:00
2020-05-31 04:46:09 +01:00
;mask ab with %00111101 11101111
push af
ld a,b
and %11101111
ld b,a
pop af
and %00111101
2020-05-31 04:23:06 +01:00
2020-05-31 04:46:09 +01:00
dec c
jr nz,.shiftLoop
2020-05-31 04:23:06 +01:00
.shiftDone
;write ba to dest
2020-05-31 04:46:09 +01:00
push af
ld a,b
ld [de],a
inc de
pop af
ld [de],a
inc de
2020-05-31 04:23:06 +01:00
pop bc
2020-05-31 04:46:09 +01:00
dec c
jr nz,.copyLoop
2020-05-31 04:23:06 +01:00
2020-05-31 04:46:09 +01:00
;restore red
ld de,fadeFinalPalette + 10
ld hl,(.stdPaletteData + (levelCheckRAM-L0203_Check2))+10
ld c,6
2020-05-31 04:23:06 +01:00
.restoreLoop
ld a,[hl+]
2020-05-31 04:46:09 +01:00
ld [de],a
inc de
dec c
jr nz,.restoreLoop
2020-05-31 04:23:06 +01:00
ld a,60
2020-05-31 04:46:09 +01:00
call FadeInit
2020-05-31 04:23:06 +01:00
.afterChangePalette
2020-05-31 04:46:09 +01:00
ret
2020-05-31 04:23:06 +01:00
.lastZone DB $ff
.stdPaletteData
DW $0068, $2108, $4210, $7fff ;Palette 0 (Grey)
DW $0068, $000A, $001f, $7fff ;Palette 1 (Red)
DW $0068, $5000, $7e00, $7fff ;Palette 2 (Blue)
DW $0068, $0140, $03e0, $7fff ;Palette 3 (Green)
DW $0068, $4008, $5192, $7fff ;Palette 4 (Purple)
DW $0068, $01cd, $03fe, $7fff ;Palette 5 (Yellow)
DW $0068, $00d1, $09ff, $7fff ;Palette 6 (Brown)
DW $0068, $4412, $799c, $7fff ;Palette 7 (Fuscia)
L0203_CheckFinished:
PRINTT " 0203 Level Check Size: "
PRINTV (L0203_CheckFinished - L0203_Check2)
PRINTT "/$500 bytes"