Added world builder

This commit is contained in:
Devine Lu Linvega 2023-01-27 11:19:39 -08:00
parent 22b59b9e81
commit 73cff56bbc
1 changed files with 166 additions and 83 deletions

View File

@ -1,12 +1,14 @@
( Oquonie )
( TODOs
> load events
> remove old blocker memory allocation
> store memory location of sprite within the event's table
> dialog event
> spellbook
> idle timer
> camera follow
> walking animation
> block on floor 0x00
> gate event locked/unlocked
> load room theme on enter
)
@ -106,9 +108,40 @@ BRK
&on-mouse-touch ( -> )
.Mouse/x DEI2 .center/x LDZ2 SUB2
.Mouse/y DEI2 .center/y LDZ2 SUB2
look-at
.Mouse/y DEI2 #03 SFT2 NIP
DUP #1a EQU ?&edit-wall
DUP #1b EQU ?&edit-floor
DUP #1c EQU ?&edit-step
BRK
&edit-wall ( y -> )
clear-room
POP .Mouse/x DEI2 #0018 DIV2 NIP
DUP get-wall #01ff .Mouse/state DEI #01 EQU JMP SWP POP ADD SWP set-wall
#00 .Mouse/state DEO
.player/room LDZ2 .player LDZ2 enter-room
BRK
&edit-floor ( y -> )
clear-room
POP .Mouse/x DEI2 #0018 DIV2 NIP
DUP get-floor #01ff .Mouse/state DEI #01 EQU JMP SWP POP ADD SWP set-floor
#00 .Mouse/state DEO
.player/room LDZ2 .player LDZ2 enter-room
BRK
&edit-step ( y -> )
clear-room
POP .Mouse/x DEI2 #0018 DIV2 NIP
DUP get-step #01ff .Mouse/state DEI #01 EQU JMP SWP POP ADD SWP set-step
#00 .Mouse/state DEO
.player/room LDZ2 .player LDZ2 enter-room
BRK
@ -125,29 +158,6 @@ BRK
JMP2r
(
@|animation )
@request-animation ( -- )
request-player-move
JMP2r
@request-player-move ( -- )
.anim/player/real/x LDZ2 .anim/player/target/x LDZ2 EQU2
.anim/player/real/y LDZ2 .anim/player/target/y LDZ2 EQU2 AND ?&skip
clear-room
.anim/player/real/x LDZ2 .anim/player/target/x LDZ2 #0004 lerp
.anim/player/real/x STZ2
.anim/player/real/y LDZ2 .anim/player/target/y LDZ2 #0002 lerp
.anim/player/real/y STZ2
draw-room
&skip
JMP2r
(
@|assets )
@ -238,52 +248,22 @@ JMP2r
DUP .player/char STZ
load-character
JMP2r
(
@|controls )
@animation-enter ( -> )
( color 3 )
.System/r DEI2 #0f AND NIP DUP #0f EQU ?&no-3
#01 ADD #00 SWP STH2
.System/r DEI2 #fff0 AND2 STH2kr ORA2 .System/r DEO2
.System/g DEI2 #fff0 AND2 STH2kr ORA2 .System/g DEO2
.System/b DEI2 #fff0 AND2 STH2r ORA2 .System/b DEO2
BRK
&no-3
POP
( color 2 )
.System/r DEI2 #04 SFT2 #0f AND NIP DUP #00 EQU ?&no-2
#01 SUB #00 SWP #40 SFT2 STH2
.System/r DEI2 #ff0f AND2 STH2kr ORA2 .System/r DEO2
.System/g DEI2 #ff0f AND2 STH2kr ORA2 .System/g DEO2
.System/b DEI2 #ff0f AND2 STH2r ORA2 .System/b DEO2
BRK
&no-2
POP
( color 1 )
.System/r DEI2 #08 SFT2 #0f AND NIP DUP #0a EQU ?&no-1
#01 SUB #00 SWP #80 SFT2 STH2
.System/r DEI2 #f0ff AND2 STH2kr ORA2 .System/r DEO2
.System/g DEI2 #f0ff AND2 STH2kr ORA2 .System/g DEO2
.System/b DEI2 #f0ff AND2 STH2r ORA2 .System/b DEO2
BRK
&no-1
POP
;on-frame .Screen/vector DEO2
BRK
@enter-room ( id* pos state -- )
( TODO: wrap in a function )
#cccc .System/r DEO2
#cccc .System/g DEO2
#cccc .System/b DEO2
;animation-enter .Screen/vector DEO2
&no-fade
set-posdir
DUP2 .player/room STZ2
load-assets
@ -291,10 +271,6 @@ BRK
JMP2r
@move-to ( pos dir -- )
.player/dir STZ
@move-pos ( pos -- )
DUP .player/pos STZ
@ -353,7 +329,7 @@ JMP2r
DUP get-event DUP2 #ffff NEQ2
?&bump
POP2
DUP tile->floor
DUP ( tile to floor ) #00 SWP ;floor-lut ADD2 LDA
DUP #ff EQU ?&wall
get-floor #00 EQU ?&hole
move-pos
@ -372,12 +348,6 @@ JMP2r
POP
JMP2r
@tile->floor ( tile -- floor )
#00 SWP ;floor-lut ADD2 LDA
JMP2r
@get-event ( tile -- <event*> )
,&t STR
@ -406,7 +376,7 @@ JMP2r
( loc ) LDA get-coordinates
#0020 SUB2 .Screen/y DEO2
.Screen/x DEO2
;cache/b draw-character
;cache/b draw-blocker
JMP2r
@ -428,7 +398,7 @@ JMP2r
&collide ( e* -- )
#0003 ADD2
INC2k INC2 LDA DUP phex/b #0a18 DEO .player/dir LDZ
INC2k INC2 LDA .player/dir LDZ
SWP2 LDA2 SWP2 enter-room
JMP2r
@ -789,6 +759,18 @@ JMP2
JMP2r
@draw-blocker ( addr* -- )
.Screen/addr DEO2
#76 .Screen/auto DEO
#f8
&l
#85 .Screen/sprite DEO
INC DUP ?&l
POP
JMP2r
@draw-character ( addr* -- )
.Screen/addr DEO2
@ -869,6 +851,9 @@ JMP2r
JMP2r
(
@|devtools )
@debug ( -- )
#0008 DUP2 .Screen/x DEO2 .Screen/y DEO2
@ -892,6 +877,7 @@ JMP2r
#0008 .Screen/x DEO2 #0018 .Screen/y DEO2
;&room-txt draw-str
.player/room LDZ2 draw-short
editor
JMP2r
&pos-txt "pos: $1
@ -899,6 +885,94 @@ JMP2r
&cam-txt "cam: $1
&room-txt "room: $1
@editor ( -- )
( walls )
#0008 .Screen/x DEO2
.Screen/height DEI2 #0020 SUB2 .Screen/y DEO2
#0600
&lw
DUP get-wall draw-byte
.Screen/x DEI2k #0008 ADD2 ROT DEO2
INC GTHk ?&lw
POP2
( floors )
#0008 .Screen/x DEO2
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#0900
&lf
DUP get-floor draw-byte
.Screen/x DEI2k #0008 ADD2 ROT DEO2
INC GTHk ?&lf
POP2
( steps )
#0008 .Screen/x DEO2
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#0600
&ls
DUP get-step draw-byte
.Screen/x DEI2k #0008 ADD2 ROT DEO2
INC GTHk ?&ls
POP2
JMP2r
(
@|animations )
@request-animation ( -- )
request-player-move
JMP2r
@request-player-move ( -- )
.anim/player/real/x LDZ2 .anim/player/target/x LDZ2 EQU2
.anim/player/real/y LDZ2 .anim/player/target/y LDZ2 EQU2 AND ?&skip
clear-room
.anim/player/real/x LDZ2 .anim/player/target/x LDZ2 #0004 lerp
.anim/player/real/x STZ2
.anim/player/real/y LDZ2 .anim/player/target/y LDZ2 #0002 lerp
.anim/player/real/y STZ2
draw-room
&skip
JMP2r
@animation-enter ( -> )
( color 3 )
.System/r DEI2 #0f AND NIP DUP #0f EQU ?&no-3
#01 ADD #00 SWP STH2
.System/r DEI2 #fff0 AND2 STH2kr ORA2 .System/r DEO2
.System/g DEI2 #fff0 AND2 STH2kr ORA2 .System/g DEO2
.System/b DEI2 #fff0 AND2 STH2r ORA2 .System/b DEO2
BRK
&no-3
POP
( color 2 )
.System/r DEI2 #04 SFT2 #0f AND NIP DUP #00 EQU ?&no-2
#01 SUB #00 SWP #40 SFT2 STH2
.System/r DEI2 #ff0f AND2 STH2kr ORA2 .System/r DEO2
.System/g DEI2 #ff0f AND2 STH2kr ORA2 .System/g DEO2
.System/b DEI2 #ff0f AND2 STH2r ORA2 .System/b DEO2
BRK
&no-2
POP
( color 1 )
.System/r DEI2 #08 SFT2 #0f AND NIP DUP #0a EQU ?&no-1
#01 SUB #00 SWP #80 SFT2 STH2
.System/r DEI2 #f0ff AND2 STH2kr ORA2 .System/r DEO2
.System/g DEI2 #f0ff AND2 STH2kr ORA2 .System/g DEO2
.System/b DEI2 #f0ff AND2 STH2r ORA2 .System/b DEO2
BRK
&no-1
POP
;on-frame .Screen/vector DEO2
BRK
(
@|helpers )
@ -915,32 +989,42 @@ JMP2r
JMP2r
@loc-id ( pos -- id )
DUP #0f AND INC #03 MUL #0f AND
SWP #04 SFT INC #0f AND ADD
#08 SWP SUB
JMP2r
@get-wall ( id -- asset )
#00 SWP .player/room LDZ2 ADD2 #0002 ADD2 LDA
JMP2r
@set-wall ( tile id -- )
#00 SWP .player/room LDZ2 ADD2 #0002 ADD2 STA
JMP2r
@get-floor ( id -- asset )
#00 SWP .player/room LDZ2 ADD2 #0008 ADD2 LDA
JMP2r
@set-floor ( tile id -- )
#00 SWP .player/room LDZ2 ADD2 #0008 ADD2 STA
JMP2r
@get-step ( id -- asset )
#00 SWP .player/room LDZ2 ADD2 #0011 ADD2 LDA
JMP2r
@set-step ( tile id -- )
#00 SWP .player/room LDZ2 ADD2 #0011 ADD2 STA
JMP2r
(
@|stdlib )
@ -998,7 +1082,6 @@ JMP2r
&s "bin/s.rom $1 ( steps )
@room-lut 06 07 08 0b 0c 0d 10 11 12
@pos-lut 08 07 05 06 04 02 03 01 00
@tiles-lut
0040 0000