mirror of
https://github.com/cc65/cc65.git
synced 2024-06-01 13:41:34 +00:00
Support for 60K MTU setup, work on asm setpixel
This commit is contained in:
parent
9c00f6628b
commit
df46a00008
41
cfg/kim1-mtu60k.cfg
Normal file
41
cfg/kim1-mtu60k.cfg
Normal file
|
@ -0,0 +1,41 @@
|
|||
# kim1-mtu60k.cfg (4k)
|
||||
#
|
||||
# for expanded KIM-1 w/ K-1008 Graphics and 60K RAM
|
||||
#
|
||||
# ld65 --config kim1-mtu60k.cfg -o <prog>.bin <prog>.o
|
||||
|
||||
FEATURES {
|
||||
STARTADDRESS: default = $2000;
|
||||
CONDES: segment = STARTUP,
|
||||
type = constructor,
|
||||
label = __CONSTRUCTOR_TABLE__,
|
||||
count = __CONSTRUCTOR_COUNT__;
|
||||
CONDES: segment = STARTUP,
|
||||
type = destructor,
|
||||
label = __DESTRUCTOR_TABLE__,
|
||||
count = __DESTRUCTOR_COUNT__;
|
||||
}
|
||||
|
||||
SYMBOLS {
|
||||
__STACKSIZE__: type = weak, value = $0080; # 128 byte program stack
|
||||
__STARTADDRESS__: type = export, value = %S;
|
||||
}
|
||||
|
||||
MEMORY {
|
||||
ZP: file = %O, define = yes, start = $0000, size = $00EE;
|
||||
CPUSTACK: file = "", define = yes, start = $0100, size = $0100;
|
||||
RAM: file = %O, define = yes, start = %S, size = $E000 - %S - __STACKSIZE__;
|
||||
MAINROM: file = "", define = yes, start = $E000, size = $1000;
|
||||
TOP: file = "", define = yes, start = $F000, size = $1000;
|
||||
}
|
||||
|
||||
SEGMENTS {
|
||||
ZEROPAGE: load = ZP, type = zp, define = yes;
|
||||
STARTUP: load = RAM, type = ro, define = yes;
|
||||
CODE: load = RAM, type = ro, define = yes;
|
||||
RODATA: load = RAM, type = ro, define = yes;
|
||||
ONCE: load = RAM, type = ro, define = yes;
|
||||
DATA: load = RAM, type = rw, define = yes;
|
||||
BSS: load = RAM, type = bss, define = yes;
|
||||
}
|
||||
|
|
@ -57,13 +57,13 @@ subs.o: subs.asm
|
|||
$(AS) subs.asm -o subs.o
|
||||
|
||||
kimLife.bin: kimLife.c
|
||||
$(CL) -t kim1 -C kim1-60k.cfg -Oi -o kimLife.bin kimLife.c
|
||||
$(CL) -t kim1 -C kim1-mtu60k.cfg -Oi -o kimLife.bin kimLife.c
|
||||
|
||||
kimTest.bin: kimTest.c
|
||||
$(CL) -t kim1 -C kim1-60k.cfg -Oi -o kimTest.bin kimTest.c
|
||||
|
||||
kimGFX.bin: kimGFX.c ramfont.c subs.o
|
||||
$(CL) -t kim1 -C kim1-60k.cfg -Oi -o kimGFX.bin kimGFX.c subs.o
|
||||
$(CL) -t kim1 -C kim1-mtu60k.cfg -Oi -o kimGFX.bin kimGFX.c subs.o
|
||||
|
||||
kimSieve.bin: kimSieve.c
|
||||
$(CL) -t kim1 -C kim1-60k.cfg -O -o kimSieve.bin kimSieve.c
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
|
||||
SCREEN = $A000
|
||||
|
||||
.segment "ZEROPAGE"
|
||||
temp: .res 1
|
||||
btpt: .res 1
|
||||
|
||||
dest = $02
|
||||
dest_lo = dest
|
||||
dest_hi = dest+1
|
||||
|
@ -25,6 +29,132 @@ src = $04
|
|||
src_lo = src
|
||||
src_hi = src+1
|
||||
|
||||
adp1 = $06
|
||||
adp1_lo = adp1
|
||||
adp1_hi = adp1+1
|
||||
|
||||
adp2 = $08
|
||||
adp2_lo = adp2
|
||||
adp2_hi = adp2+1
|
||||
|
||||
x1cord = $0A
|
||||
x1cord_lo = x1cord
|
||||
x1cord_hi = x1cord+1
|
||||
|
||||
y1cord = $0C
|
||||
y1cord_lo = y1cord
|
||||
y1cord_hi = y1cord+1
|
||||
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
;-----------------------------------------------------------------------------------
|
||||
; GetPixelAddress - Calculate the address of a pixel in the video memory
|
||||
;-----------------------------------------------------------------------------------
|
||||
; Based on MTU PIXADR code
|
||||
;-----------------------------------------------------------------------------------
|
||||
; x - x1cord (16-bit)
|
||||
; y - y1cord (16-bit)
|
||||
; adp2 - address of pixel to set (16-bit)
|
||||
;-----------------------------------------------------------------------------------
|
||||
|
||||
_GetPixelAddress:
|
||||
lda x1cord ; compute bit address first
|
||||
sta adp1 ; also transfer x1cord to adp1
|
||||
and #$07 ; + which is simply the low 3 bits of x
|
||||
sta btpt
|
||||
|
||||
lda x1cord+1 ; finish transferring x1cord to adp1
|
||||
sta adp1+1
|
||||
lsr adp1+1 ; double shift adp1 right 3 to get
|
||||
ror adp1 ; int(xcord/8 )
|
||||
lsr adp1+1
|
||||
ror adp1
|
||||
lsr adp1+1
|
||||
ror adp1
|
||||
lda #199 ; transfer (199-y1cord) to adp2
|
||||
sec ; and temporary storage
|
||||
sbc y1cord
|
||||
sta adp2
|
||||
sta temp
|
||||
|
||||
lda #0
|
||||
sbc y1cord+1
|
||||
sta adp2+1
|
||||
sta temp+1
|
||||
asl adp2 ; compute 40*(199-y1cord)
|
||||
rol adp2+1 ; 2*(199-y1cord)
|
||||
asl adp2
|
||||
rol adp2+1 ; 4*(199-y1cord)
|
||||
lda adp2 ; add in temporary save of (199-y1cord)
|
||||
clc ; to make 5*(199-y1cord)
|
||||
adc temp
|
||||
sta adp2
|
||||
lda adp2+1
|
||||
adc temp+1
|
||||
sta adp2+1 ; 5*(199-y1cord)
|
||||
asl adp2 ; 10*(199-y1cord)
|
||||
rol adp2+1
|
||||
asl adp2 ; 20#(199-y1cord)
|
||||
rol adp2+1
|
||||
asl adp2 ; 40*(199-y1cord)
|
||||
rol adp2+1
|
||||
lda adp2 ; add in int(x1cord/8) computed earlier
|
||||
clc
|
||||
adc adp1
|
||||
sta adp1
|
||||
lda adp2+1
|
||||
adc adp1+1
|
||||
adc #>SCREEN ; add in base vidscreen address
|
||||
sta adp1+1 ; final result
|
||||
rts ; return
|
||||
|
||||
;-----------------------------------------------------------------------------------
|
||||
; Mask tables for individual pixel subroutines
|
||||
;
|
||||
; MSKTB1 is a table of 1 bits corresponding to bit numbers
|
||||
; MSKTB2 is a table of 0 bits corresponding to bit numbers
|
||||
;-----------------------------------------------------------------------------------
|
||||
|
||||
msktb1: .byte $80,$40,$20,$10,$08,$04,$02,$01
|
||||
msktb2: .byte $7F,$BF,$DF,$EF,$F7,$FB,$FD,$FE
|
||||
|
||||
;-----------------------------------------------------------------------------------
|
||||
; SetPixel - Set a pixel in the video memory
|
||||
;-----------------------------------------------------------------------------------
|
||||
; x - x1cord (16-bit)
|
||||
; y - y1cord (16-bit)
|
||||
;-----------------------------------------------------------------------------------
|
||||
; Mask tables for individual pixel subroutines
|
||||
;-----------------------------------------------------------------------------------
|
||||
|
||||
_SetPixel: jsr _GetPixelAddress
|
||||
ldy btpt ; get bit number in y
|
||||
lda msktb1,y ; get a byte with that bit =1, others =0
|
||||
ldy #0
|
||||
ora (adp1),y ; combine the bit with the addressed vm
|
||||
sta (adp1),y ; byte
|
||||
rts
|
||||
|
||||
;-----------------------------------------------------------------------------------
|
||||
; ClearPixel - Clears a pixel in the video memory
|
||||
;-----------------------------------------------------------------------------------
|
||||
; x - x1cord (16-bit)
|
||||
; y - y1cord (16-bit)
|
||||
;-----------------------------------------------------------------------------------
|
||||
|
||||
_ClearPixel: jsr _GetPixelAddress
|
||||
ldy btpt ; get bit number in y
|
||||
lda msktb2,y ; get a byte with that bit =0, others =1
|
||||
ldy #0
|
||||
and (adp1),y ; remove the bit from the addressed vm
|
||||
sta (adp1),y ; byte
|
||||
rts
|
||||
|
||||
;-----------------------------------------------------------------------------------
|
||||
; ClearScreen - Clears the entire video memory (and thus the screen)
|
||||
;-----------------------------------------------------------------------------------
|
||||
|
||||
_ClearScreen:
|
||||
lda #$00
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user