lawless-legends/Platform/Apple/virtual/src/plasma/gameloop.pla

100 lines
2.2 KiB
Plaintext
Raw Normal View History

;==================================================================================================
2014-06-25 15:47:28 +00:00
; Handy constants.
const FALSE = 0
const TRUE = !FALSE
;==================================================================================================
2014-06-25 15:47:28 +00:00
; Hardware addresses.
const keyboard = $C000
const keystrobe = $C010
2014-07-06 14:40:57 +00:00
const ptr = $6000
const f1 = 0
const f2 = 2
;==================================================================================================
; Strings.
byte hellostr[] = "Hello, world.\n"
2014-07-06 14:40:57 +00:00
byte str2[] = "Second.\n"
predef func1, func2
word myclass
word table = @func1, @func2
;==================================================================================================
; Definitions used by assembly code
asm __defs
; Zero-page
TMPL = $6
TMPH = $7
ESTKL = $C0
ESTKH = $D0
; Memory bank manipulation
LCRDEN = $C080
LCWTEN = $C081
ROMEN = $C082
LCRWEN = $C083
LCBNK2 = $00
LCBNK1 = $08
; ROM routines
PRBYTE = $FDDA
COUT = $FDED
end
;==================================================================================================
; Print a string
asm puts
TXA
PHA
LDA ESTKL,X
2014-06-25 15:47:28 +00:00
STA TMPL
LDA ESTKH,X
2014-06-25 15:47:28 +00:00
STA TMPH
LDY #0
LDA (TMPL),Y
2014-06-25 15:47:28 +00:00
TAX
INY
2014-06-25 15:47:28 +00:00
BIT ROMEN
- LDA (TMPL),Y
ORA #$80
JSR COUT
INY
DEX
BNE -
2014-06-25 15:47:28 +00:00
BIT LCRDEN+LCBNK2
PLA
TAX
2014-07-06 14:40:57 +00:00
RTS
end
;==================================================================================================
; Print a 16-bit hex value, followed by a space
asm printHex
BIT ROMEN
LDA ESTKH,X
JSR PRBYTE
2014-07-06 14:40:57 +00:00
LDA ESTKL,X
JSR PRBYTE
2014-07-06 14:40:57 +00:00
LDA #$A0
JSR COUT
2014-07-06 14:40:57 +00:00
BIT LCRDEN+LCBNK2
2014-06-25 15:47:28 +00:00
RTS
end
;==================================================================================================
2014-06-25 15:47:28 +00:00
; Main loop.
;
2014-07-06 14:40:57 +00:00
def func1()
printHex(1)
end
def func2()
printHex(2)
end
2014-07-06 14:40:57 +00:00
myclass = @table
table.f2()
;(myclass).f2()
((myclass):f2)()
puts(@hellostr)
func1(@hellostr)
2014-06-25 15:47:28 +00:00
done