[Coco] silly assembler fun
Kevin Diggs
kevdig at hypersurf.com
Thu Oct 7 14:55:23 EDT 2004
Hi,
Here is a minimally entertaining little program to
not-so-pseudo-randomly set pixels on the G1C (64x64x4) screen. The
random number generator is the simple random algorithm adapted from the
book "Inner Loops". I think it is more entertaining than most of what is
on television. Though the new Always Bad Channel (aka ABC) series Lost
seems ok.
Anyone know if G1C can be used under OS-9? In other words, is there
anyway for me to say "I'll set and control the graphic hardware. Trust
Me." to the OS? From what I remember it (OS-9)only supports the 6k modes.
I can probably provide an assembled audio file if anyone is interested
(Linux only).
I might be smart enough to write some games ... except for the sound.
Anyone out there who knows how to do sound willing to teach the masses?
Nick, any arrangement we could come to so I could get the source for
the Pacman game? I could certainly learn alot from you! I don't
understand why you don't try to sell this on EBay? Are you worried about
copyrights?
kevin
rdotg1c:
* org $1eb adjust to align on 2 page boundary
*vbuf rmb 1024 buffer for g1c mode
vbuf equ $600 address of basic graphic page 1
start bsr sg1c
sta $ffd6 clear hybrid speed mode
ldd #vbuf
lsra
bsr svaddr
bsr gclr
bra mloop
stlen equ .-start
*
gclr ldx #vbuf
leay 1024,x
pshs y
clgtop clr ,x+
cmpx ,s
bne clgtop
leas 2,s
gcdone rts
gclen equ .-gclr
*
sg1c ldx #$ff22
lda ,x
anda #7
ora #$80
sta ,x
leax $9f,x $ff22 + $9f = $ffc1 -> x
sta ,x+
sta ,x++
sta ,x
sgdone rts
sg1len equ .-sg1c
*
sa ldx $ff22
lda ,x
anda #7
ora $8
sta ,x
leax $9e,x $ff22 + $9e = $ffc0 -> x
sta ,x++
sta ,x++
sta ,x
sadone rts
salen equ .-sa
*
svaddr ldx $ffc6
ldb #7
pshs b
svtop clrb
lsra
adcb #0
sta b,x
leax 2,x
dec ,s
bne svtop
leas 1,s
svdone rts
svalen equ .-svaddr
*
mloop nop
noise leax seed,pcr
pshs x
lbsr simran
leay prod,pcr
puls x
ldd ,x++
std ,y
ldd ,x
std 2,y
lda 3,y
ldb 2,y
stb 4,y
ldb 1,y
stb 3,y
ldb ,y
andb #$f
stb 2,y
sta 1,y
lda ,y
lsra
lsra
lsra
lsra
sta ,y
ldd 2,y
lsra
rorb
lsra
rorb
eora 3,y
eorb 4,y
lda 3,y
anda #$3
sta 3,y
ldx #vbuf
ldd 3,y
leax d,x
ldd ,y
pshs a
eorb ,s
tfr b,a
lsra
lsra
lsra
lsra
sta ,s
eorb ,s
andb #$f
tfr b,a
lsra
lsra
sta ,s
lda #3
andb #3
beq pmok
pmsh lsla
lsla
lsl ,s
lsl ,s
decb
bne pmsh
pmok coma
anda ,x
ora ,s+
sta ,x
jsr [$a000]
beq noise
cmpa #'q
beq bye
cmpa #'c
bne chkr
lda $ff22
eora #$8
sta $ff22
lbra noise
chkr cmpa #'r
bne chkf
lbsr gclr
lbra noise
chkf cmpa #'f
bne chkn
sta $ffd9
lbra noise
chkn cmpa #'n
bne nexkey
sta $ffd8
nexkey lbra noise
bye lbsr sa
lda #2
lbsr svaddr
sta $ffd8
mldone rts
mllen equ .-mloop
*
simran leay mcand,pcr
leau prod,pcr
bsr mul3x4
leau prod,pcr
leau 4,u
ldx 2,s
ldd ,u++
std ,x++
ldd ,u++
std ,x++
leay radd,pcr
leay 4,y
andcc #$fe
ldb #4
addtop lda ,-y
adca ,-x
sta ,x
decb
bne addtop
sidone rts
simlen equ .-simran
*
mul3x4 lda #8 clr dest
cltop clr ,u+
deca
bne cltop
leax 4,x x points to byte above lsbyte
leay 2,y y ponts to lsbyte
pshs u,x
lda #3
pshs a outter loop count
otop ldx 1,s
ldu 3,s
lda #4
pshs a inner loop count
itop lda ,-x
ldb ,y
mul
addb ,-u
stb ,u
adca -1,u
sta -1,u
bcc noc
pshs u
leau -1,u
ctop inc ,-u ripple carry
beq ctop
puls u
noc dec ,s
bne itop
leas 1,s
leay -1,y
ldu 3,s
leau -1,u
stu 3,s
dec ,s
bne otop
leas 5,s
mudone rts
mulen equ .-mul3x4
zclen equ .-start
radd fdb #3c6e
fdb #f35f
seed fdb $99
fdb $99
mcand fcb $19
fcb $66
fcb $0d
prod rmb 8
zdlen equ .-radd
end
More information about the Coco
mailing list