rendered paste body; Program Name:
; Author:
; Version:
; Date:
; Written for Doors CS 6.0 and higher (http://dcs.cemetech.net)
.nolist
#include "dcs6.inc"
.list
.org progstart
.db $BB,$6D
Init:
xor d
ret
jr Start
.dw Description ;or .dw $0000 if you don't have a description
.db $06,$00 ;always this string
.dw Icon ;or .dw $0000 if you don't have an icon
.dw $0000 ;usually .dw $0000 if you don't have or know what an ALE is
Start: ;main routines
newGame:
di
xor a
ld b,11
ld hl,board
ngLoop1:
ld (hl),a
inc hl
djnz ngLoop1
PlayerTurn:
call checkWin
xor a
inc a
ld (turn),a
ld de,0
push de
call closeGUIStack
call openGUIStack
ld hl,mainWin
ld de,bt_mainWin-mainWin
ld a,GUIRSmallWin
call PushGUIStack
ld hl,bt_mainWin
ld de,Description-bt_mainWin
ld a,GUIRWinButtons
call PushGUIStack
ld hl,bt_newGame
ld de,Description-bt_newGame
ld a,GUIRButtonText
call PushGUIStack
ld hl,bt_quit
ld de,mainWin-bt_quit
ld a,GUIRButtonText
call PushGUIStack
ld hl,hs_1
ld de,hs_2-hs_1
ld a,GUIRHotspot
call PushGUIStack
ld hl,hs_2
ld de,hs_3-hs_2
ld a,GUIRHotspot
call PushGUIStack
ld hl,hs_3
ld de,bt_quit-hs_3
ld a,GUIRHotspot
call PushGUIStack
;
ld hl,hs_4
ld de,hs_5-hs_4
ld a,GUIRHotspot
call PushGUIStack
ld hl,hs_5
ld de,hs_6-hs_5
ld a,GUIRHotspot
call PushGUIStack
ld hl,hs_6
ld de,hs_1-hs_6
ld a,GUIRHotspot
call PushGUIStack
;
ld hl,hs_7
ld de,hs_8-hs_7
ld a,GUIRHotspot
call PushGUIStack
ld hl,hs_8
ld de,hs_9-hs_8
ld a,GUIRHotspot
call PushGUIStack
ld hl,hs_9
ld de,hs_4-hs_9
ld a,GUIRHotspot
call PushGUIStack
call drawboard
ld hl,0
call GUIMouse
space9:
inc de
space8:
inc de
space7:
inc de
space6:
inc de
space5:
inc de
space4:
inc de
space3:
inc de
space2:
inc de
space1:
ld hl,board
add hl,de
ld a,(hl)
or a
jp nz,playerTurn
xor a
inc a
ld (hl),a
push de
call checkWin
pop de
ld a,e
cp 3
jr c,PRow1
sub 3
cp 3
jr c,PRow2
sub 3
PRow3:
sla a
sla a
add a,e
sla a
add a,10
ld l,38
ld ix,spr_X
call putsprite8
call ifastcopy
jr AITurn
PRow2:
sla a
sla a
add a,e
sla a
add a,10
ld l,28
ld ix,spr_X
call putsprite8
call ifastcopy
jr AITurn
PRow1:
sla a
sla a
add a,e
sla a
add a,10
ld l,18
ld ix,spr_X
call putsprite8
call ifastcopy
AITurn:
call checkWin
jp PlayerTurn
checkWin:
ret
exitProg:
call ResetAppPage
ret
drawBoard:
ld hl,spr_board
ld de,data_end-spr_board
ld a,GUIRLargeSprite
call PushGUIStack
ret
turn: .db 1
board:
.db 0,0,0
.db 0,0,0
.db 0,0,0
cursorX: .db 0
cursorY: .db 0
hs_7:
.db 3
.db 25
.db 10
.db 10
.dw space7
hs_8:
.db 14
.db 25
.db 10
.db 10
.dw space8
hs_9:
.db 25
.db 25
.db 10
.db 10
.dw space9
hs_4:
.db 3
.db 14
.db 10
.db 10
.dw space4
hs_5:
.db 14
.db 14
.db 10
.db 10
.dw space5
hs_6:
.db 25
.db 14
.db 10
.db 10
.dw space6
hs_1:
.db 3
.db 3
.db 10
.db 10
.dw space1
hs_2:
.db 14
.db 3
.db 10
.db 10
.dw space2
hs_3:
.db 25
.db 3
.db 10
.db 10
.dw space3
bt_quit:
.db 61
.db 9
.dw exitProg
.db "Quit",0
mainWin:
.db 7
.db 7
.db %11111000
.db %10001000
.db %10101000
.db %10001000
.db %11111000
.db "Tic-Tac-Toe",0
bt_mainWin:
.db %00100000
.dw 0
.dw exitProg
.dw 0
bt_newGame:
.db 41
.db 1
.dw newGame
.db "New Game",0
Description:
.db "Test",0 ;can be omitted if .dw Description is .dw 0000 above
Icon: ;a 16x16 icon (can be omitted if .dw Icon is .dw 0000 above)
.db %11111111,%11111000
.db %10000000,%00001100
.db %10111100,%00001010
.db %10010010,%00001111
.db %10010010,%01010001
.db %10010010,%10101001
.db %10111100,%01010101
.db %10000000,%00000001
.db %10101010,%10101001
.db %10010101,%01010101
.db %10101010,%10101001
.db %10000000,%00000001
.db %10010101,%01010101
.db %10101010,%10101001
.db %10000000,%00000001
.db %11111111,%11111111
spr_X:
.db %10000001
.db %01000010
.db %00100100
.db %00011000
.db %00011000
.db %00100100
.db %01000010
.db %10000001
spr_O:
.db %00111100
.db %01000010
.db %10000001
.db %10000001
.db %10000001
.db %10000001
.db %01000010
.db %00111100
spr_board:
.db 3
.db 3
.db 4
.db 32
.db $00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00
.db $00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00
.db $00,$20,$04,$00,$00,$20,$04,$00,$FF,$FF,$FF,$FF,$00,$20,$04,$00
.db $00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00
.db $00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00
.db $00,$20,$04,$00,$FF,$FF,$FF,$FF,$00,$20,$04,$00,$00,$20,$04,$00
.db $00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00
.db $00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00,$00,$20,$04,$00
data_end: