Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 76645ec592
Fetching contributors…

Cannot retrieve contributors at this time

968 lines (799 sloc) 16.032 kb
set pc, main
; "," to face left
; "." to face right
; "<space>" to move forward
;=================================================
;===| Drawing Functions
;=================================================
;=================================================
;===| Draw Door Facing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawDoorFacing
; locals:
set push, x
set push, y
set push, z
set push, a
; top left of door
set x, 11
set y, 3
; --- calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x2000
set x, 0x000b
set y, 0x0003
set z, 0x0009
set a, 0x2001
jsr drawHorizontalLine
; right of door
set x, 21
set y, 2
set z, 7
set a, 0x2006
jsr drawVerticalLine
; left of door
set x, 0x000b
set y, 3
set z, 6
set a, 0x2006
jsr drawVerticalLine
:drawDoorFacing_end
set a, pop
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Draw Door Right Near
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawDoorRightNear
; locals:
set push, x
set push, y
set push, z
set push, a
; top right of door
set x, 29
set y, 2
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x2009
; top left of door
set x, 28
set y, 2
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x2008
; bottom right of door
set x, 27
set y, 9
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x200a
; left of door
set x, 27
set y, 2
set z, 6
set a, 0x2007
jsr drawVerticalLine
; right of door
set x, 29
set y, 2
set z, 7
set a, 0x2007
jsr drawVerticalLine
:drawDoorRightNear_end
set a, pop
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Draw Door Left Near
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawDoorLeftNear
; locals:
set push, x
set push, y
set push, z
set push, a
; top left of door
set x, 2
set y, 2
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x200b
; top right of door
set x, 3
set y, 2
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x200c
; bottom right of door
set x, 3
set y, 9
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x200a
; left of door
set x, 2
set y, 2
set z, 7
set a, 0x2006
jsr drawVerticalLine
; right of door
set x, 3
set y, 2
set z, 6
set a, 0x2007
jsr drawVerticalLine
:drawDoorLeftNear_end
set a, pop
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Draw Door Right Far
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawDoorRightFar
; locals:
set push, x
set push, y
set push, z
set push, a
; top left of door
set x, 23
set y, 4
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x2009
; top right of door
set x, 22
set y, 4
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x2008
; bottom right of door
set x, 23
set y, 8
; Calculate location on screen
jsr calculateCoordinateLocation
set x, z
set [x], 0x200a
; left of door
set x, 22
set y, 4
set z, 3
set a, 0x2006
jsr drawVerticalLine
; right of door
set x, 23
set y, 4
set z, 3
set a, 0x2007
jsr drawVerticalLine
:drawDoorRightFar_end
set a, pop
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Draw Near Wall Outline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawMainWindow
; locals:
set push, x
set push, y
set push, z
set x, 0
set y, 0
set z, 0x001f
jsr drawSquareTop
set x, 0
set y, 0x000a
set z, 0x001f
;jsr drawSquareBottom
set x, 0
set y, 0x0000
set z, 0x000a
jsr drawSquareLeft
set x, 0x001f
set y, 0x0000
set z, 0x000a
jsr drawSquareRight
:drawMainWindow_end
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Draw Middle Wall Outline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawMiddle
; locals
set push, x
set push, y
set push, z
set x, 0x0006
set y, 0x0003
set z, 0x0013
jsr drawSquareTop
set x, 0x0006
set y, 0x0008
set z, 0x0013
;jsr drawSquareBottom
set x, 0x0006
set y, 0x0003
set z, 0x0005
jsr drawSquareLeft
set x, 0x0019
set y, 0x0003
set z, 0x0005
jsr drawSquareRight
:drawMiddle_end
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Draw Far Wall Outline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawFar
; locals:
set push, x
set push, y
set push, z
set x, 0x000b
set y, 0x0005
set z, 0x0009
jsr drawSquareTop
set x, 0x000b
set y, 0x0007
set z, 0x0009
;jsr drawSquareBottom
set x, 0x000b
set y, 0x0005
set z, 0x0002
jsr drawSquareLeft
set x, 0x0034
set y, 0x0004
set z, 0x0002
jsr drawSquareRight
:drawFar_end
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Draw Wall Facing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawWallFacing
; locals:
set push, x
set push, y
set push, z
set push, a
set x, 0x0000
set y, 0x0003
set z, 0x001e
set a, 0x2001
jsr drawHorizontalLine
set x, 0x0000
set y, 0x0008
set z, 0x001e
set a, 0x2001
jsr drawHorizontalLine
:drawWallFacing_end
set a, pop
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Other Drawings
;=================================================
;===| Clear Screen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:clearScreen
; locals:
set push, x
; Calculate location on screen
set x, 0x8000
:clearNextCoordinate
set [x], 0x0000
add x, 1
ifg 0x817f, x
set pc, clearNextCoordinate
:clearScreen_end
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;===| Draw Lines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawHorizontalLine
;Input:
; x - X coordinate of line origin
; y - Y coordinate of line origin
; z - length of line
; a - character to draw
; locals:
set push, i
; Calculate location on screen
set push, z
jsr calculateCoordinateLocation
set x, z
set z, pop
set i, 0
:drawHorizontalLine_loop
add x, 1
add i, 1
set [x], a
ifg z, i
set PC, drawHorizontalLine_loop
:drawHorizontalLine_end
set i, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawVerticalLine
;Input:
; x - X coordinate of line origin
; y - Y coordinate of line origin
; z - length of line
; a - character to draw
; locals:
set push, i
; Calculate location on screen
set push, z
jsr calculateCoordinateLocation
set x, z
set z, pop
set i, 0
:drawVerticalLine_loop
add x, 0x0020
add i, 1
set [x], a
ifg z, i
set PC, drawVerticalLine_loop
:drawVerticalLine_end
set i, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;===| Draw Square Components
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawSquareTop
;Input:
; x - X coordinate of line origin
; y - Y coordinate of line origin
; z - length of line
; locals:
set push, i
; Calculate location on screen
set push, z
jsr calculateCoordinateLocation
set x, z
set z, pop
set [x], 0x2000
set i, 0
:drawSquareTop_loop
add x, 1
add i, 1
set [x], 0x2001
ifg z, i
set PC, drawSquareTop_loop
set [x], 0x2002
:drawSquareTop_end
set i, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawSquareBottom
;Input:
; x - X coordinate of line origin
; y - Y coordinate of line origin
; z - length of line
; locals:
set push, i
; Calculate location on screen
set push, z
jsr calculateCoordinateLocation
set x, z
set z, pop
set [x], 0x2003
set i, 0
:drawSquareBottom_loop
add x, 1
add i, 1
set [x], 0x2004
ifg z, i
set PC, drawSquareBottom_loop
set [x], 0x2005
:drawSquareBottom_end
set i, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawSquareLeft
;Input:
; x - X coordinate of line origin
; y - Y coordinate of line origin
; z - length of line
; locals:
set push, i
; Calculate location on screen
set push, z
jsr calculateCoordinateLocation
set x, z
set z, pop
set i, 0
:drawSquareLeft_loop
add x, 0x0020
add i, 1
set [x], 0x2006
ifg z, i
set PC, drawSquareLeft_loop
:drawSquareLeft_end
set i, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawSquareRight
;Input:
; x - X coordinate of line origin
; y - Y coordinate of line origin
; z - length of line
; locals:
set push, i
; Calculate location on screen
set push, z
jsr calculateCoordinateLocation
set x, z
set z, pop
set i, 0
:drawSquareRight_loop
add x, 0x0020
add i, 1
set [x], 0x2007
ifg z, i
set PC, drawSquareRight_loop
:drawSquareRight_end
set i, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:initStart
; locals:
set PUSH, a
set PUSH, b
set PUSH, c
; load tiles
set b, 0x001a
set c, 0x8180
set a, border0
jsr loadtiles
:initStart_end
set c, pop
set b, pop
set a, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| View Drawings
;=================================================
;===| Draw Tunnel
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawTunnel
jsr drawMainWindow
jsr drawMiddle
jsr drawFar
:drawTunnel_end
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;===| Draw Floor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawFloor
; parameters:
; x - room number
; locals:
set push, a
set a, x
add a, [roomDataLength]
sub a, 1
ife [a], 0x0000
set pc, drawFloor_end
; -----
set push, x
set push, y
set push, z
set x, 9
set y, 10
jsr calculateCoordinateLocation
set [z], 0x2041
set z, pop
set y, pop
set x, pop
:drawFloor_end
set a, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Utilities
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:loadtiles
; Parameters:
; A = Data to Read
; B = Length
; C = Destination
; locals
set push,i
set i, 0
:loadtiles_loop
SET [c], [a]
ADD a, 1
ADD i, 1
ADD c, 1
IFE i, b
SET PC, loadtiles_end
SET PC, loadtiles_loop
:loadtiles_end
set i, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:calculateCoordinateLocation
; Input: X, Y Cartesian Coordinates
; Output: Z for binary location
; locals:
set push, a
set z, 0x8000
set a, 0x0020
mul a, y
add z, a
add z, x
:calculateCoordinateLocation_end
set a, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
;=================================================
;===| Data
;===| Compass Directions
:compassDirection DAT 0x204e, 0x2045, 0x2053, 0x2057
;===| View Descriptions
:viewTunnel DAT 0x0001
:viewWall DAT 0x0002
:viewDoor DAT 0x0003
;===| Floor Items
:floorItem001 DAT 0x0001
;===| Location Details (N/E/S/W View/Adjoinings)
; format:
; 1-4 Facings (N, E, S, W)
; 5-8 Next Room (N, E, S, W)
; 9 Floor
:roomDataLength DAT 0x0009
:room001 DAT 0x0001, 0x0002, 0x0001, 0x0003, 0x0002, 0x0000, 0x0003, 0x0004, 0x0001
:room002 DAT 0x0002, 0x0003, 0x0001, 0x0002, 0x0000, 0x0005, 0x0001, 0x0000, 0x0001
:room003 DAT 0x0001, 0x0002, 0x0002, 0x0002, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000
:room004 DAT 0x0002, 0x0003, 0x0002, 0x0002, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000
:room005 DAT 0x0002, 0x0003, 0x0002, 0x0003, 0x0000, 0x0006, 0x0000, 0x0002, 0x0000
:room006 DAT 0x0003, 0x0002, 0x0002, 0x0003, 0x0007, 0x0000, 0x0000, 0x0005, 0x0000
:room007 DAT 0x0002, 0x0002, 0x0003, 0x0002, 0x0000, 0x0000, 0x0006, 0x0000, 0x0000
;===| Room Messages
; 1 Length
; 2-x characters
:message001 DAT 0x0005 0x2053 0x2074 0x2061 0x2072 0x2074
;===| Border Tiles
:border0 DAT 0xff01, 0x0101 ; 0x8180 top left
:border1 DAT 0x0101, 0x0101 ; 0x8181 top
:border2 DAT 0x0101, 0x01ff ; 0x8182 top right
:border3 DAT 0xff80, 0x8080 ; 0x8183 bottom left
:border4 DAT 0x8080, 0x8080 ; 0x8184 bottom
:border5 DAT 0x8080, 0x80ff ; 0x8185 bottom right
:border6 DAT 0xff00, 0x0000 ; 0x8186 left
:border7 DAT 0x0000, 0x00ff ; 0x8187 right
;===| Door Tiles
:doorRight0 DAT 0x8040, 0x2010 ; 0x8188 top left
:doorRight1 DAT 0x0804, 0x02ff ; 0x8189 top right
:doorRight2 DAT 0x0000, 0x001f ; 0x818a bottom right
:doorLeft0 DAT 0xff02, 0x0408 ; 0x818b top left
:doorLeft1 Dat 0x1020, 0x4080 ; 0x818c top right
;=================================================
;=================================================
;===| Main logic
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:main
jsr initStart
; locals
set b, 0 ; keyboard buffer
set x, room001 ; player starting location
set j, 1 ; facing
jsr drawView
jsr drawStartLocation
:inputLoop
ife [0x9000+b], 0
set pc, inputLoop
jsr clearScreen
; calculate action based on keypress
ife [0x9000+b], 0x002e ; turn right
add j, 1
ife [0x9000+b], 0x002c ; turn left
sub j, 1
ife j, 5
set j, 1
ife j, 0
set j, 4
ife [0x9000+b], 0x0020 ; move forward
jsr moveForward
; increment keyboard buffer pointer
set [0x9000+b], 0
add b, 1
ife b, 16
set b, 0
; Draw player's view, depending on facing
jsr drawView
ife x, room001
jsr drawStartLocation
ife x, room007
jsr drawEndLocation
set pc, inputLoop
; inifite loop at the end, otherwise, it falls through to some weird code and mucks up my screen
:main_end
set pc, main_end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:moveForward
; parameters
; x - current room
; locals
set push, a
set push, b
; get next room based on facing
set a, x
add a, 3
add a, j
ife [a], 0x0000
set pc, moveForward_end
set x, room001
set b, [a]
sub b, 1
mul b, [roomDataLength]
add x, b
:moveForward_end
set b, pop
set a, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawView
; parameters:
; x - room location
; locals:
; a - work variable
set push, a
; determine facing view based on room+facing
set a, x ; set room
add a, j ; add facing to room
sub a, 1
ife [a], [viewTunnel]
jsr drawTunnel
ife [a], [viewDoor]
jsr drawDoorFacing
ife [a], [viewWall]
jsr drawWallFacing
;-----
set push, z
set push, a
set a, compassDirection
add a, j
sub a, 1
set z, [a]
jsr displayCompassDirection
set a, pop
set z, pop
;-----
:drawView_end
set a, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawStartLocation
set push, x
set push, y
set push, z
set push, i
set push, j
set push, a
; -----
set x, 1
set y, 11
jsr calculateCoordinateLocation
set a, [message001]
set j, 1
:message_loop
set [z], [message001+j]
add j, 1
ifg j, a
set pc, drawStartLocation_end
add z, 1
set pc, message_loop
:drawStartLocation_end
set a, pop
set j, pop
set i, pop
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:drawEndLocation
set push, x
set push, y
set push, z
; -----
set x, 1
set y, 11
jsr calculateCoordinateLocation
set [z], 0x2045
add z, 1
set [z], 0x206e
add z, 1
set [z], 0x2064
:drawEndLocation_end
set z, pop
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; \
:displayCompassDirection
; parameters:
; z - direction text character
; locals
set push, x
set push, y
; -----
set push, z
set x, 16
set y, 11
jsr calculateCoordinateLocation
set x, z
set z, pop
set [x], z
; -----
:displayCompassDirection_end
set y, pop
set x, pop
set pc, pop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /
;=================================================
Jump to Line
Something went wrong with that request. Please try again.