I had this idea last night, for trying to demonstrate what DCS is capable of. I'm going to modify ZTris and give it nice GUI-fied menus. I've already been working on in for ~2 hours this morning. my code so far if anyone cares.
Working since about 8 this morning, I'm finally done. Still needs debugging, though.
Code:
Code:
And here's ztris.z80
Code:
Yegads, that's a long post.
Code:
Code:
; Program Name: ZTris, DCS showcase version
; Author: Peter Marheine, originally by Tijl Coosemans
; Version: 1.0
; Date: 4/13/07
; Written for Doors CS 6 or higher (http://dcs.cemetech.net)
.nolist
.include "dcs6.inc"
#DEFINE NULL 0
#DEFINE diff(dat, dat2) .dw dat2 - dat
#DEFINE bcall(xxxx) rst 28h \ .dw xxxx
_clrScrnBuf =4BD0h
_divHLby10 =400Fh
_getcsc =4018h
_ldHLind =4009h
_putc =4504h
_putmap =4501h
_puts =450Ah
_vputmap =455Eh
_vputs =4561h
fastCopy =4092h
HtimesL =40B6h
receiveByte =40A1h
sendByte =409Eh
setupint =4191h
setVPuts =40A7h
currow =844Bh
curcol =844Ch
pencol =86D7h
penrow =86D8h
screenBuf =9340h
safeRam =9872h + 73 ;need those first 73 bytes for GUI routines
decomp =safeRam
penLines =safeRam+8
opponentStatus =safeRam+9
vdispHLStr =safeRam+10
height =safeRam+16
sendBuf1 =safeRam+17
sendBuf2 =safeRam+18
sendBuf3 =safeRam+19
counter =safeRam+20
nxtPceBufOffset =safeRam+21
rgrpSendLines =0 ;group for send lines radio buttons
rgrpScrmLinex =1 ; " scramble lines
.list
.org 9D93h
.db 0BBh,6Dh
Init:
xor d
ret
jr Start
.dw description
.db 05h,00h
.dw icon
.dw NULL
Start:
;;initialize game
ld a,r
ld (randSeed+1),a
;ld a,00001100b ; enable tasker and apd
;call setupint
;;DCS doesn't do the tasker, this would just waste memory
set 7,(iy+20)
restartGame:
ld hl,safeRam+15
xor a
ld b,7
initGameLoop:
ld (hl),a
inc hl
djnz initGameLoop
ld hl,resume
or (hl)
jp nz,drawLevel
;=================================================
; Build primary menu
;=================================================
menuInit:
call openGUIStack
ld a,GUIRLargeWin
ld hl,priWinDat
ld de,diff(priWinDat, priWinTaskB)
call pushGUIStack
ld a,GUIRWinButtons
ld hl,priWinTaskB
ld de,7
call pushGUIStack
ld a,GUIRText
ld hl,priWinTitle
ld de,diff(priWinTitle, playbutton)
call pushGUIStack
ld a,GUIRButtonText
ld hl,playButton
ld de,diff(playButton, optsButton)
call pushGUIStack
ld a,GUIRButtonText
ld hl,optsButton
ld de,diff(optsButton, scoresButton)
call pushGUIStack
ld a,GUIRButtonText
ld hl,exitButton
ld de,diff(exitButton, authTxt)
call pushGUIStack
ld a,GUIRWrappedText
ld hl,authTxt
ld de,diff(authTxt, scoresWinDat)
call pushGUIStack
priWinReady:
ld hl,0
call GUIMouse ;*foom* control is gone
;;when we return here, we've played a game or viewed high scores
jr priWinReady
;=================================================
; onclick(exitButton)
;=================================================
Exit:
call resetAppPage
pop hl ;don't want to return to priWinReady
call CloseGUIStack ;clean up the GUI (kill priWin)
ret ;exit
;=================================================
; onclick(scoresButton)
;=================================================
scoresOpen:
call resetAppPage
ld a,GUIRSmallWin
ld hl,scoresWinDat
ld de,diff(scoresWinDat, scoresWinTaskB)
call pushGUIStack
ld a,GUIRWinButtons
ld hl,scoresWinTaskB
ld de,diff(scoresWinTaskB, highScoreTexts)
call pushGUIStack
ld a,3
highScore_winDatCopy:
ld hl,highScoreTable
ld de,highScoreTexts_Spork
ld bc,13
ldir
inc hl
inc hl
inc hl
inc de
dec a
jr nz,highScore_winDatCopy
ld a,GUIRWrappedText
ld hl,highScoreTexts
ld de,diff(highScoreTexts, scoresWinEnd)
call pushGUIStack
ld hl,0
call GUIMouse
;;only one possible action here - exit
closeScoresWin:
call resetAppPage
pop hl
ld b,3
call PopGUIStacks
ret
;=================================================
; onclick(optsButton)
;=================================================
;config data in gameOptions, one byte
;usage, by bit
;1: scrmLines status (scrambled/unscrambled to send)
;2: status of sendLines (1-3/2-4, I think)
;3: set for two-player, reset for one
;stLevel is the level to begin on (0-9)
;stHeight is starting height (0-5)
openOptsMenu:
call resetAppPage
ld a,GUIRLargeWin
ld hl,optsWinDat
ld de,diff(optsWinDat, optsWinLevlSpin)
call pushGUIStack
ld a,GUIRByteInt
ld hl,optsWinLevlSpin
ld de,diff(optsWinLevlSpin, optsWinLevlSpinLbl)
call pushGUIStack
ld a,GUIRText
ld hl,optsWinLevlSpinLbl
ld de,diff(optsWinLevlSpinLbl, optsWinHiSpin)
call pushGUIStack
ld a,GUIRByteInt
ld hl,optsWinHiSpin
ld de,diff(optsWinHiSpin, optsWinHiSpinLbl)
call pushGUIStack
ld a,GUIRText
ld hl,optsWinHiSpinLbl
ld de,diff(optsWinHiSpinLbl, optsWinSendRad1)
call pushGUIStack
ld a,GUIRRadio
ld hl,optsWinSendRad1
ld de,diff(optsWinSendRad1, optsWinSendRad2)
call pushGUIStack
ld a,GUIRRadio
ld hl,optsWinSendRad2
ld de,diff(optsWinSendRad2, optsWinButtonOK)
call pushGUIStack
;;I'm too lazy to add optsWinScrmRad1 & 2 now
ld a,GUIRButtonText
ld hl,optsWinButtonOK
ld de,diff(optsWinButtonOK, optsWinButtonCancel)
call pushGUIStack
ld a,GUIRButtonText
ld hl,optsWinButtonCancel
ld de,diff(optsWinButtonCancel, optsWin_End
call pushGUIStack
call GUIMouse
;;woot, that took too long
optsMenuApply:
call resetAppPage
call GUIFindFirst
push hl
inc hl
inc hl
ld a,(hl)
ld (stLevel),a
pop hl
call GUIFindNext
call GUIFindNext
push hl
inc hl
inc hl
ld a,(hl)
ld (stHeight),a
pop hl
call GUIFindNext
call GUIFindNext
inc hl
inc hl
inc hl
ld a,(hl)
xor 1
rla
rla
ld hl,gameOptions
res 2,(hl)
or (hl)
ld (hl),a
optsWinClose:
call resetAppPage
ld b,9
call popGUIStacks
pop hl
ret
;=================================================
; priWin objects
;=================================================
priWinDat:
.db 01111000b
.db 11000000b
.db 00001000b
.db 00111000b
.db 00100000b
.db "ZTris (DCS Showcase)",0
priWinTaskB:
.db 00100000b ;only show close button
.dw NULL
.dw NULL
.dw Exit
priWinTitle:
.db 1
.db 1
.db 0
.db "ZTris for DCS6",0
playButton:
.db 2
.db 10
.dw playGame
.db "Play the game",0
optsButton:
.db 2
.db 20
.dw openOptsMenu
.db "Change settings",0
scoresButton:
.db 2
.db 30
.dw scoresOpen
.db "High scores",0
exitButton:
.db 2
.db 40
.dw Exit
.db "Exit :(",0
authTxt:
.db 2
.db 50
.db 58
.db 0
.db "Modified for DCS by",0D6h
.db "Peter Marheine",0
;=================================================
; scoresWin objects
;=================================================
scoresWinDat:
.db 7
.db 7
.db 10101000b
.db 01010000b
.db 10101000b
.db 01010000b
.db 10101000b
.db "High scores",0
scoresWinTaskB:
.db 00100000b
.dw 0
.dw 0
.dw closeScoresWin
highScoreTexts:
.db 0
.db 0
.db 40
.db 0
highScoreTexts_Spork:
.db "1. ----------",0D6h ;needs space for the score, too. ignore for now
.db "2. ----------",0D6h
.db "3. ----------",0
scoresWin_End:
;=================================================
; optsWin objects
;=================================================
optsWinDat:
.db 11110000b
.db 00100000b
.db 01010000b
.db 11111000b
.db 00010000b
.db "ZTris settings",0
optsWinLevlSpin:
.db 24
.db 2
.db 0
.db 0
.db 9
optsWinLevlSpinLbl:
.db 1
.db 1
.db 0
.db "Level ",0
optsWinHiSpin:
.db 58
.db 2
.db 0
.db 0
.db 5
optsWinHiSpinLbl:
.db 30
.db 1
.db 0
.db "Height ",0
optsWinSendRad1:
.db 1
.db 20
.db rgrpSendLines
.db 1
.db "Send 1-3",0
optsWinSendRad2:
.db 1
.db 28
.db rgrpSendLines
.db 0
.db "Send 2-4",0
optsWinButtonOK:
.db 5
.db 50
.dw optsMenuApply
.db "Accept",0
optsWinButtonCancel:
.db 35
.db 50
.dw optsWinClose
.db "Cancel",0
optsWin_End:
;=================================================
; Header info
;=================================================
description:
.db "ZTris for DCS",0
icon:
.db 00000000b,00000000b
.db 01111110b,11100000b
.db 01111110b,00111100b
.db 01111110b,01001000b
.db 01110000b,10001000b
.db 01110000b,11101000b
.db 01110000b,00001000b
.db 01110000b,00000000b
.db 01110001b,11000000b
.db 01110001b,11000000b
.db 00000001b,11000000b
.db 00001111b,11111000b
.db 00001111b,11111000b
.db 00001111b,11111000b
.db 00000000b,00000000b
.include "ztris.z80"
.end
END
And here's ztris.z80
Code:
;===========================================================================
; * Play Game *
;===========================================================================
playGame:
;;I'm lazy, this message should be GUI-fied eventually
ld hl,waitingTxt
ld de,0303h
call fastPuts
call linkSend
jr nz,startGame
playWait:
bcall(_getcsc)
halt
or a
jp nz,restartGame
call linkReceive
jr nc,playWait
startGame:
call getNewPce
call z,linkSend
call getNewPce
call z,linkSend
call z,linkSend
ld hl,gameData
xor a
ld b,4
initGame:
ld (hl),a
inc hl
djnz initGame
inc hl
inc hl
ld b,19
initBoardLoop:
ld (hl),11100000b
inc hl
ld (hl),00000111b
inc hl
djnz initBoardLoop
ld a,(gameOptions)
bit 3,a
jr z,noResume
dec (hl)
noResume:
inc hl
ld a,(hl)
inc hl
ld (hl),a
inc hl
ld a,(hl)
ld (height),a
drawLevel:
ld hl,patterns
ld a,(level)
cp 16
jr c,drawPattern
ld a,15
drawPattern:
add a,a
add a,a
add a,a
ld d,0
ld e,a
add hl,de
ld de,screenBuf
ld bc,0808h
drawScreenLoop:
push bc
push hl
ld b,c
drawOneRowLoop:
ld a,(hl)
ld c,12
drawOneLineLoop:
ld (de),a
inc de
dec c
jr nz,drawOneLineLoop
inc hl
djnz drawOneRowLoop
pop hl
pop bc
djnz drawScreenLoop
drawGaps:
ld hl,gaps
ld a,4
drawGapsLoop:
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld c,(hl)
inc hl
push hl
ex de,hl
ld de,9
makeGap:
ld b,3
clearOneLine:
ld (hl),d
inc hl
djnz clearOneLine
add hl,de
dec c
jr nz,makeGap
pop hl
dec a
jr nz,drawGapsLoop
drawBoardLines:
ld hl,screenBuf+4
ld e,6
ld b,64
drawBoardLinesLoop:
ld a,(hl)
or 01h
ld (hl),a
add hl,de
ld a,(hl)
or 80h
ld (hl),a
add hl,de
djnz drawBoardLinesLoop
ld hl,gameInfoTxt
ld de,0209h
call setVPuts
ld d,18
call setVPuts
ld d,34
call setVPuts
ld hl,(nxtPce)
ld de,0402h
xor a
call drawPce
ld hl,height
ld a,(hl)
ld (hl),0
add a,a
ld b,a
jr nz,addHeightLines
jr chkStatus
addLinesChk:
ld hl,penLines
xor a
ld b,(hl)
ld (hl),a
cp b
jr z,drawStatus
push bc
ld hl,cPcePos
ld a,(hl)
add a,b
cp 16
jr c,topNotReached
ld a,15
topNotReached:
ld (hl),a
ld a,b
add a,a
ld b,0
ld c,a
ld hl,board+37
ld d,h
ld e,l
sbc hl,bc
sub 36
neg
ld c,a
lddr
pop bc
ld a,(gameOptions)
bit 1,a
addHeightLines:
ld a,10
call z,genRandom
ld hl,board+2
addLinesLoop:
push bc
push hl
ld de,1111111111111111b
ld b,5
addLineGaps:
push af
call nz,genRandom
inc a
ld hl,1111111111111011b
rotateWordLoop:
sl1 l
rl h
dec a
jr nz,rotateWordLoop
ld a,d
and h
ld d,a
ld a,e
and l
ld e,a
pop af
djnz addLineGaps
pop hl
ld (hl),d
inc hl
ld (hl),e
inc hl
pop bc
djnz addLinesLoop
chkStatus:
ld hl,board+33
ld b,16
chkStatusLoop:
ld e,(hl)
dec hl
ld d,(hl)
dec hl
push hl
ld hl,$E007
or a
sbc hl,de
pop hl
jr nz,chkStatusDone
djnz chkStatusLoop
chkStatusDone:
ld a,b
or 80h
ld (sendBuf1),a
ld a,(gameOptions)
bit 3,a
jr nz,dispScore
drawStatus:
ld a,(opponentStatus)
add a,a
add a,a
ld de,winTxt
jp c,gameWin
inc a
ld c,a
ld a,66
sub c
ld b,a
ld hl,screenBuf+11
ld de,12
jr drawStatus1
drawStatusLoop1:
ld a,(hl)
and 0Fh
ld (hl),a
add hl,de
drawStatus1:
djnz drawStatusLoop1
ld b,c
jr drawStatus2
drawStatusLoop2:
ld a,(hl)
and 0Fh
or 60h
ld (hl),a
add hl,de
drawStatus2:
djnz drawStatusLoop2
dispScore:
ld hl,(score+2)
ld h,0
bcall(_divHLby10)
ld (score+2),a
ld de,(score)
add hl,de
ld (score),hl
ld de,9*256+12
ld b,5
call vdispHL
ld de,25*256+24
ld a,(level)
ld b,2
call vdispA
ld de,41*256+20
ld a,(lines)
ld b,3
call vdispA
drawBoard:
ld l,16
drawBoardLoop1:
ld h,10
drawBoardLoop2:
push hl
ld a,h
add a,10
ld h,a
call drawBlock
pop hl
dec h
jr nz,drawBoardLoop2
dec l
jr nz,drawBoardLoop1
ld hl,(cPce)
ld de,(cPcePos)
ld a,(cPceRot)
push af
push de
call drawPce
call fastCopy
pop de
pop af
call testPce
jp nz,gameOver
;===========================================================================
; * Main Input Loop *
;===========================================================================
inputLoop:
call linkReceive
push af
call linkSendChk
pop af
jp nz,addLinesChk
ld hl,counter
dec (hl)
jr z,fallDown
ld de,(cPcePos)
ld a,(cPceRot)
ld b,a
bcall(_getcsc)
halt
cp 15
jp z,gameOver
cp 40
jr z,drop
dec a
jr z,moveDown
dec a
jr z,moveLeft
dec a
jr z,moveRight
dec a
jr z,rotateRight
cp 48-4
jr z,rotateLeft
sub 54-4
jr z,rotateRight
ld hl,gameOptions
bit 3,(hl)
jr z,inputLoop
dec a
jr nz,inputLoop
pause: call showTitleScrn
call fastCopy
ld hl,pauseTxt
ld de,0403h
call fastPuts
pauseGetKey:
bcall(_getcsc)
halt
sub 55
jr nz,pauseGetKey
ld (counter),a
jp drawLevel
moveDown:
ld hl,score+2
inc (hl)
fallDown:
call resetCounter
ld de,(cPcePos)
ld a,(cPceRot)
dec e
call testPce
jp z,dispScore
jr newPce
moveLeft:
dec d
dec d
moveRight:
inc d
inc b
rotateLeft:
dec b
dec b
rotateRight:
inc b
update:
call testPceN
jp drawBoard
drop:
push bc
ld hl,score+2
inc (hl)
dec e
call testPceN
pop bc
jr z,drop
call resetCounter
newPce:
ld hl,decomp
ld b,4
storePceLoop:
push hl
bcall(_ldHLind)
ld de,(cPcePos)
add hl,de
call getBlock
or (hl)
ld (hl),a
pop hl
inc hl
inc hl
djnz storePceLoop
chkLines:
ld hl,board+2
ld bc,36*256
chkLinesLoop:
push hl
bcall(_ldHLind)
inc hl
ld a,h
or l
pop hl
jr nz,nxtRow
push bc
push hl
ld d,h
ld e,l
inc hl
inc hl
ld c,b
ld b,a ; a = 0
ldir
pop hl
pop bc
inc c
jr chkLinesLoop
nxtRow: inc hl
inc hl
dec b
djnz chkLinesLoop
ld a,c
cp 2
jr c,nopenalty
ld a,(gameOptions)
rra
rra
sub c
neg
ld (sendBuf2),a
nopenalty:
ld hl,scoring
add hl,bc
ld l,(hl)
ld a,(level)
inc a
ld h,a
call HtimesL
ld de,(score)
add hl,de
ld (score),hl
ld a,(lines)
add a,c
ld (lines),a
ld l,a
ld h,0
bcall(_divHLby10)
ld a,l
ld hl,level
cp (hl)
jr c,nonewlvl
ld (hl),a
nonewlvl:
call getNewPce
jp drawLevel
resetCounter:
ld hl,levelCnts
ld a,(level)
call pointHLindA
ld (counter),a
ret
;===========================================================================
; * Game Over *
;===========================================================================
gameOver:
ld a,$FF
ld (sendBuf1),a
call linkReceive
call linkSendChk
ld de,gameOverTxt
gameWin:
xor a
ld (resume),a
flashText:
;;more stuff that should be GUI-fied
ld b,20
flashWait:
bcall(_getcsc)
halt
cp 5
jr nc,chkHighScore
djnz flashWait
ld a,(iy+5)
xor 8
ld (iy+5),a
push de
call fastCopy
ld de,0303h
pop hl
push hl
call fastPuts
pop de
jr flashText
chkHighScore:
res 3,(iy+5)
ld hl,highScoreTable+14
ld b,3
chkHighScoreLoop:
push hl
bcall(_ldHLind)
ld de,(score)
sbc hl,de
pop hl
jr c,highScore
ld de,16
add hl,de
djnz chkHighScoreLoop
highScoreDone:
jp restartGame
highScore:
push de
ld a,b
ld hl,highScoreTable+31
ld de,highScoreTable+47
jr moveHighScores
moveHighScoresLoop:
ld bc,15
lddr
dec hl
dec de
moveHighScores:
dec a
jr nz,moveHighScoresLoop
pop hl
ex de,hl
ld (hl),d
dec hl
ld (hl),e
dec hl
ld b,10
clearHighScore:
dec hl
ld (hl),' '
djnz clearHighScore
push hl ;->high score to write
;;removed junk, replaced with GUI
ld a,GUIRSmallWin
ld hl,nameInputWin
ld de,diff(nameInputWin, nameInputBox)
call pushGUIStack
ld de,nameInputBox+5
pop hl
push hl
ld bc,10
ldir
ld a,GUIRTextLineIn
ld hl,nameInputBox
ld de,diff(nameInputBox, nameInputOK)
call pushGUIStack
ld a,GUIRButtonText
ld hl,nameInputOK
ld de,diff(nameInputOK, nameInput_End)
call pushGUIStack
call GUIMouse
;;only one way out- click OK
nameInputAccept:
call resetAppPage
call GUIFindFirst
ld de,5
add hl,de
pop de ;from the call to GUIMouse
pop de ;->where to write
ld bc,10
ldir
ret
nameInputWin:
.db 7
.db 7
.db 01010000b
.db 01010000b
.db 01010000b
.db 00000000b
.db 01010000b
.db "Enter name",0
nameInputBox:
.db 0
.db 0
.db 20
.db 10
.db 0
.db 0,0,0,0,0,0,0,0,0,0,0
nameInputOK:
.db 0
.db 10
.dw nameInputAccept
.db "OK",0
nameInput_End:
;===========================================================================
; * Routines *
;===========================================================================
testPceN:
ld a,b
testPce:
push af
ld hl,(cPce)
call uncrunch
testPceLoop:
push hl
push de
bcall(_ldHLind)
add hl,de
call getBlock
and (hl)
pop de
pop hl
jr nz,testPceDone
inc hl
inc hl
djnz testPceLoop
testPceDone:
pop hl
ret nz
ld a,h
ld (cPceRot),a
ld (cPcePos),de
ret
getNewPce:
ld hl,(nxtPce)
ld (cPce),hl
ld hl,14*256+15
ld (cPcePos),hl
xor a
ld (cPceRot),a
ld b,a
ld hl,nxtPceBufOffset
cp (hl)
push af
jr z,createNewPce
ld c,(hl)
dec (hl)
inc hl
ld a,(hl)
ld d,h
ld e,l
inc hl
ldir
jr initNewPce
createNewPce:
ld a,7
call genRandom
inc a
ld (sendBuf3),a
initNewPce:
add a,a
add a,a
add a,a
ld c,a
ld hl,pieces-8
add hl,bc
ld (nxtPce),hl
pop af
ret
drawPce:
call uncrunch
drawPceLoop:
push hl
push de
bcall(_ldHLind)
add hl,de
call putBlock
pop de
pop hl
inc hl
inc hl
djnz drawPceLoop
ret
drawBlock:
push hl
call getBlock
and (hl)
pop hl
jr z,eraseBlock
putBlock:
call getScreenLoc
ret c
or (hl)
jr drawBlockLoop
eraseBlock:
call getScreenLoc
ret c
cpl
and (hl)
drawBlockLoop:
ld (hl),a
add hl,de
dec c
jr nz,drawBlockLoop
ret
getBlock:
ld a,l
add a,a
ld l,a
ld a,h
add a,240
jr nc,getBlock1
inc l
getBlock1:
and 00000111b
inc a
ld h,a
ld a,00000001b
getBlockLoop1:
rrca
dec h
jr nz,getBlockLoop1
ld de,board
add hl,de
ret
getScreenLoc: ; hl is address of (h,l) in screenBuf
ld a,16
sub l
ret c
add a,a
add a,a
ld l,a
ld a,h
ld h,0
ld d,h
ld e,l
add hl,de
add hl,de
add hl,hl
add hl,hl
ld e,a
dec e
rr e
add hl,de
ld de,screenBuf
add hl,de
and 1
ld a,00001111b
ld c,4
ld de,12
ret z
cpl
ret
uncrunch: ; Extracts the piece from compressed data
push de
and 00000011b
call pointHLind2A
ld de,decomp
push de
ld b,8
uncrunchLoop:
ld a,l
and 00000011b
ld (de),a
inc de
rr h
rr l
rr h
rr l
djnz uncrunchLoop
ld b,4
pop hl
pop de
ret
linkReceive:
di
in a,(2)
rla
jr nc,TI83Plus
TI83PlusSE:
in a,(9)
and 18h
jr chkReceive
TI83Plus:
in a,(0)
and 03h
cp 03h
chkReceive:
ret z
call receiveByte
ld (opponentStatus),a
call receiveByte
ld (penLines),a
call receiveByte
cp 1
ret c
ld hl,nxtPceBufOffset
inc (hl)
ld c,(hl)
ld b,0
add hl,bc
ld (hl),a
ret
linkSend:
ld a,80h
ld (sendBuf1),a
linkSendChk:
ld a,(gameOptions)
bit 3,a
ret nz
ld hl,sendBuf1
ld a,(hl)
or a
ret z
call linkSendByte
call linkSendByte
linkSendByte:
ld a,(hl)
ld (hl),0
inc hl
push hl
call sendByte
pop hl
xor a
ret
showTitleScrn:
bcall(_clrScrnBuf)
ld a,-7
ld (penrow),a
ld hl,titleTxt
ld b,8
showTitle:
ld a,(penrow)
add a,8
ld d,a
ld e,2
ld (pencol),de
ld a,(hl)
inc hl
bcall(_vputmap)
djnz showTitle
bcall(_vputs)
ld hl,screenBuf
ld de,12
ld b,64
invertTitle:
ld a,(hl)
xor $FE
ld (hl),a
add hl,de
djnz invertTitle
ret
;===========================================================================
; * Utility Routines *
;===========================================================================
vdispA: ld h,0
ld l,a
vdispHL:
push de
ld de,vdispHLStr+5
vdispHLLoop:
dec de
bcall(_divHLby10)
add a,30h
ld (de),a
djnz vdispHLLoop
ex de,hl
pop de
jp setVPuts
fastPuts:
ld (currow),de
bcall(_puts)
ret
fastPutDigit:
add a,30h
fastPutmap:
ld (currow),hl
bcall(_putmap)
ret
genRandom:
di
exx
ld c,a
ex af,af'
ld hl,0
randSeed =$+1
ld de,0001h
ld a,75
ld b,8
randomLoop:
add hl,hl
jr nc,$+3
dec hl
rla
jr nc,$+6
add hl,de
jr nc,$+3
dec hl
djnz randomLoop
ld (randSeed),hl
ld d,b
ld e,h
ld h,b
ld l,b
ld b,c
add hl,de
djnz $-1
ex af,af'
ld a,h
exx
ret
pointHLind2A:
add a,a
pointHLindA:
ld d,0
ld e,a
add hl,de
bcall(_ldHLind)
ret
;===========================================================================
; * Text *
;===========================================================================
waitingTxt:
.db "* WAITING *",0
gameInfoTxt:
.db "Score",0
.db "Level",0
.db "Lines",0
pauseTxt:
.db "* PAUSE *",0
gameOverTxt:
.db " Game Over ",0
winTxt:
.db " You Win ",0
highScoreTxt:
.db "You have a high score!",0
.db "Enter your name",0
;===========================================================================
; * Data *
;===========================================================================
highScoreTable:
.db "1. ----------",0,0,0
.db "2. ----------",0,0,0
.db "3. ----------",0,0,0
patterns: ; Pattern for each level
.db $AA,$55,$AA,$55,$AA,$55,$AA,$55
.db $88,$FF,$22,$FF,$88,$FF,$22,$FF
.db $FF,$99,$99,$FF,$FF,$99,$99,$FF
.db $50,$D7,$14,$F7,$00,$F7,$14,$D7
.db $EA,$AA,$AE,$00,$57,$55,$75,$00
.db $FE,$AA,$AA,$AA,$28,$AA,$FE,$00
.db $55,$55,$AA,$AA,$55,$55,$AA,$AA
.db $80,$FE,$02,$FB,$08,$EF,$20,$BF
.db $EE,$EE,$EE,$00,$77,$77,$77,$00
.db $66,$CC,$99,$33,$66,$CC,$99,$33
.db $CC,$33,$CC,$33,$CC,$33,$CC,$33
.db $FE,$82,$BA,$AA,$BA,$82,$FE,$00
.db $CC,$CC,$33,$33,$CC,$CC,$33,$33
.db $FF,$AA,$FF,$AA,$FF,$AA,$FF,$AA
.db $7C,$FE,$7C,$00,$7C,$FE,$7C,$00
.db $FF,$EF,$47,$12,$B8,$FD,$FF,$FF
gaps: ; Gaps where the pattern shouldn't be shown
.dw screenBuf+25 \ .db 14
.dw screenBuf+217 \ .db 14
.dw screenBuf+409 \ .db 14
.dw screenBuf+601 \ .db 12
pieces: ; Compressed data of the pieces (28 pieces)
.dw 0001010110011000b,0110010100000100b
.dw 0010000101011001b,0110101001010100b
.dw 0001010110010000b,0010011001010100b
.dw 0001010110011010b,0110010101001000b
.dw 0101100101001000b,0101100101001000b
.dw 0101100101001000b,0101100101001000b
.dw 0001010110010100b,0001011001010100b
.dw 0001011001011001b,0110010101001001b
.dw 0000010101001001b,0010000101010100b
.dw 0000010101001001b,0010000101010100b
.dw 0001010101001000b,0001000001100101b
.dw 0001010101001000b,0001000001100101b
.dw 0001010110011101b,0111011001010100b
.dw 0001010110011101b,0111011001010100b
scoring: ; Score for each level
.db 0,4,10,30,120
levelCnts:
.db 120,108,96,84,75,66,57,51,45,39
.db 33,29,25,21,18,15,12,9,6,3,1
gameData:
score: .dw 0
.db 0
lines: .db 0
board: .db 255,255 ; bottom
.db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; visible area
.db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;
.db 0,0,0,0 ; invisible area
.db 0,0 ; top
resume: .db 0
stLevel:
.db 0
level: .db 0
stHeight:
.db 0
gameOptions:
.db 8
nxtPce: .dw 0
cPce: .dw 0
cPcePos:
.dw 0
cPceRot:
.db 0
;===========================================================================
.end
Yegads, that's a long post.
Eh, I largely left ztris.z80 unmodified. The GUI elements are basically just a wrapper to the gameplay, which is unmodified, except for the high score entry code.
tifreak8x wrote:
Twouldn't hurt my feelings to see some of the other asm classics set up for DCS.
What would you suggest? Any programs in particular? Oooh, how about a Phoenix version?
Hmm...
phoenix
falldown
tunnel
Otherwise, I guess it would be a matter of deciding from the list at ticalc, or creating your own.
phoenix
falldown
tunnel
Otherwise, I guess it would be a matter of deciding from the list at ticalc, or creating your own.
HAHAHAHA
You do realize that the code itself would have to be majorly overhauled for such a project?? I SERIOUSLY doubt Kerm would take the time to do that.
Elfprince needs to get on stratcon...
You do realize that the code itself would have to be majorly overhauled for such a project?? I SERIOUSLY doubt Kerm would take the time to do that.
Elfprince needs to get on stratcon...
I know =D I didnt think it would be possible really, but some others would be.. hm... dunno. Kerm, is there any possible way to shrink the screen size of a program, and make it playable in a DCS style window? If so you could play more then one game at once =D... orrr, have a docDE file minimized that you could pull up when a teacher walked by =D
KermMartian wrote:
tifreak8x wrote:
Twouldn't hurt my feelings to see some of the other asm classics set up for DCS.
What would you suggest? Any programs in particular? Oooh, how about a Phoenix version?beat ya to it: http://www.ticalc.org/archives/files/fileinfo/393/39359.html
elfprince13 wrote:
beat ya to it: http://www.ticalc.org/archives/files/fileinfo/393/39359.html
Not seeing any DCS 6 specific GUI elements - wasn't that the point of the ZTetris 'remake'?
Pseudoprogrammer wrote:
I know =D I didnt think it would be possible really, but some others would be.. hm... dunno. Kerm, is there any possible way to shrink the screen size of a program, and make it playable in a DCS style window? If so you could play more then one game at once =D... orrr, have a docDE file minimized that you could pull up when a teacher walked by =D
The GUI system is set up to be able to do something like that, but I didn't implement the TSE code to do it.
@Kllrnohj: yeah, same...
All this work with the GUI code has led me to something that may be useful: a massPushGUIStack routine, similar to popGUIStacks. Being forced to set up pointers and calls to pushGUIStack is a huge waste of both programmers' time and memory. If we can just set up structures which get copied into the GUI stack, it'll be much easier/smaller/faster.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
» Goto page 1, 2, 3 Next
» View previous topic :: View next topic
» View previous topic :: View next topic
Page 1 of 3
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Advertisement