Skip to content

Commit

Permalink
Added first draft of well processing
Browse files Browse the repository at this point in the history
  • Loading branch information
picosonic committed Jan 3, 2024
1 parent 5443e7b commit c2120c0
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 36 deletions.
4 changes: 4 additions & 0 deletions beeb/consts.asm
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ TITLEROOM = 0
BEANSTALKROOM = 1
FIREROOM = 2
HEARTSROOM = 3
UNDERAUSROOM = 7
STRANGENEWROOM = 23
GAMESTARTROOM = 36
WELLROOM = 39
ENTRANCEHALLROOM = 52
TOPWELLROOM = 55
ALLOTMENTROOM = 58

DIZZY_WIDTH = (3*8)
Expand Down
57 changes: 55 additions & 2 deletions beeb/dizzy3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ INCLUDE "gfx.asm"
PAGE_ROOMDATA

LDA #&01:STA dontupdatedizzy ; Stop Dizzy being drawn
STA upsidedown:DEC upsidedown ; Make sure we're not upsidedown

LDA #TITLEROOM:STA roomno
JSR roomsetup
Expand Down Expand Up @@ -156,6 +157,55 @@ INCLUDE "gfx.asm"
; See if room changed
LDA newroomno:CMP roomno:BEQ notanewroom

; only a problem if newroomno =23 or 55
; when roomno=39
; or if newroomno=39 (set path to tumble)

; Check if we've just left the well
LDA roomno
CMP #WELLROOM:BEQ leaving39

; Check if we went down from Australia
LDA newroomno
CMP #UNDERAUSROOM:BEQ fallenoutof23
CMP #WELLROOM:BNE gotoenterroom

; Gone down from Australia (into well)
.fallenoutof23
LDA #WELLROOM:STA newroomno
; set to ordinary tumble
LDA roomno:STA lastroom
BNE gotoenterroom

; Leaving well, if into Australia, then vertical flip
.leaving39
LDA newroomno
CMP #STRANGENEWROOM:BEQ flipandsettumble

; notroom23
; were going up on seq. 8
LDA lastroom
CMP #TOPWELLROOM:BEQ skipthis
LDA #TOPWELLROOM:BNE settojumpout
.skipthis
LDA #STRANGENEWROOM

.settojumpout
STA newroomno
; set path to jump (+ve x)
JMP gotoenterroom

.flipandsettumble
; set path to upside down tumble
LDA #90:STA dizzyy

; Switch upsidedown
LDA upsidedown
EOR #&01:STA upsidedown

; Go through the well a second time
LDA #WELLROOM:STA newroomno

.gotoenterroom
JSR enterroom
LDA #&00:STA dontupdatedizzy
Expand All @@ -178,8 +228,11 @@ INCLUDE "gfx.asm"
LDA completedgame:BNE quitted

.notdonegame
LDA killed:BEQ maingamelp
DEC killed:LDA killed:BNE maingamelp
LDA killed:BEQ restartloop
DEC killed:LDA killed:BEQ keepgoing
.restartloop
JMP maingamelp
.keepgoing

LDA #&01:STA dontupdatedizzy ; Stop Dizzy being drawn

Expand Down
75 changes: 41 additions & 34 deletions beeb/gfx.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
uselookup = 1

; Wait for vertical trace
.waitvsync
{
Expand Down Expand Up @@ -307,44 +305,22 @@ PAL_DIZZY2 = &02
JMP done
.cont

IF uselookup = 0
; Point to start of top left of position to draw frame
LDA #MODE8BASE DIV 256:STA zptr3+1:STA zptr2+1
LDA #MODE8BASE MOD 256:STA zptr3:STA zptr2

; Advance to X/Y position
LDA frmy
BEQ noy
LSR A:LSR A ; Divide Y by 4
AND #&FE
STA yjump+2 ; Store result as operand for ADC below
LDA zptr3+1
.yjump
CLC:ADC #&00
STA zptr3+1:STA zptr2+1

; Add small y offset
LDA frmy
AND #&07
STA ztmp4
CLC:ADC zptr3:STA zptr3:STA zptr2
.noy
ENDIF

IF uselookup = 1
TXA:PHA
LDX frmy
;TXA:PHA
LDA frmy:TAX:TAY
LDA upsidedown:BEQ noflip
LDA #MAXY+(5*8):SEC:SBC frmy:TAY
TAX
.noflip
LDA screentable_hi, X
STA zptr3+1:STA zptr2+1

LDA screentable_lo, X
STA zptr3:STA zptr2
PLA:TAX
;PLA:TAX

LDA frmy
TYA
AND #&07
STA ztmp4
ENDIF

LDA frmx:AND #&7F
BEQ nox ; Don't advance pointer if it's 0
Expand Down Expand Up @@ -450,6 +426,9 @@ ENDIF
CMP ztmp1
BNE rowloop ; Go round again if we haven't completed the row

LDA upsidedown
BNE drawupsidedown
{
INC ztmp4

; Reset to start of row, but one down
Expand All @@ -465,6 +444,29 @@ ENDIF
LDA zptr3:SBC #&08:STA zptr3:STA zptr2
LDA zptr3+1:CLC:ADC #&02:STA zptr3+1:STA zptr2+1
.nodiv8
JMP drawdone
}

.drawupsidedown
{
DEC ztmp4

; Reset to start of row, but one up
LDA #&00:STA zidx2
DEC zptr3:LDA zptr3:STA zptr2
LDA zptr3+1:STA zptr2+1

; If we're divisible by 8, need to move to bottom of next cell up
LDA ztmp4
AND #&07
CMP #&07
BNE nodiv8
LDA zptr3:CLC:ADC #&08:STA zptr3:STA zptr2
LDA zptr3+1:SEC:SBC #&02:STA zptr3+1:STA zptr2+1
.nodiv8
}

.drawdone

; Check to see if we've drawn all the source bytes
LDA zidx1:CMP ztmp3:BEQ done
Expand Down Expand Up @@ -687,8 +689,12 @@ ENDIF
;
; Pointer to message in zptr5

; Cache upsidedown state
LDA upsidedown:PHA

; Disable clipping so we can print room name, lives and coin counts
LDA #&00:STA cliptoplayarea
STA upsidedown ; Also force upsidedown off

LDY #&00

Expand Down Expand Up @@ -937,6 +943,9 @@ ENDIF
.done
LDA #&01:STA cliptoplayarea

; Restore upsidedown state
PLA:STA upsidedown

RTS

; Message variables
Expand Down Expand Up @@ -1183,7 +1192,6 @@ ENDIF
RTS
}

IF uselookup = 1
; Lookup table for start of each line of the screen in memory
;
; high bytes are : 50,50,50,50,50,50,50,50 52,52,52,52,52,52,52,52...
Expand All @@ -1206,4 +1214,3 @@ ALIGN &100
NEXT
NEXT
}
ENDIF
Binary file modified beeb/progress.odt
Binary file not shown.
2 changes: 2 additions & 0 deletions beeb/vars.asm
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ endif
.printloops EQUB 0 ; Number of remaining loops when doing print repeats
.printidx EQUB 0 ; Place to loop back to on repeats

.upsidedown EQUB 0 ; Vertical flip flag

.zpend

; ---------------------------------------------------------
Expand Down

0 comments on commit c2120c0

Please sign in to comment.