mirror of
https://github.com/cc65/cc65.git
synced 2024-12-22 12:30:41 +00:00
atari5200 update: simple conio "hello world" works now
This commit is contained in:
parent
ec417c0dc5
commit
92b32d7d0e
@ -55,10 +55,11 @@ PADDL5 = $16 ;POT5 "
|
||||
PADDL6 = $17 ;POT6 "
|
||||
PADDL7 = $18 ;POT7 "
|
||||
|
||||
; cc65 runtime zero page variables
|
||||
|
||||
.importzp COLCRS_5200
|
||||
.importzp ROWCRS_5200
|
||||
|
||||
COLCRS_5200 = $19
|
||||
ROWCRS_5200 = $1A
|
||||
SAVMSC = $1B ; pointer to screen memory (conio)
|
||||
|
||||
;-------------------------------------------------------------------------
|
||||
; Page #2
|
||||
|
@ -5,7 +5,7 @@ SYMBOLS {
|
||||
__RESERVED_MEMORY__: type = export, value = $0200; # space for display list and 20x24 screen buffer
|
||||
}
|
||||
MEMORY {
|
||||
ZP: file = "", start = $0019, size = $00E7, define = yes;
|
||||
ZP: file = "", start = $001D, size = $00E3, define = yes;
|
||||
RAM: file = "", start = $021C, size = $4000 - __STACKSIZE__ - __RESERVED_MEMORY__ - $021C, define = yes;
|
||||
ROM: file = %O, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - $18, define = yes, fill = yes, fillval = $FF;
|
||||
CARTNAME: file = %O, start = $BFE8, size = $0014 fill = yes, fillval = $40;
|
||||
|
67
libsrc/atari5200/conioscreen.s
Normal file
67
libsrc/atari5200/conioscreen.s
Normal file
@ -0,0 +1,67 @@
|
||||
|
||||
.include "atari5200.inc"
|
||||
|
||||
SCREEN_BUF_SIZE = 20 * 24
|
||||
SCREEN_BUF = $4000 - SCREEN_BUF_SIZE
|
||||
|
||||
.code
|
||||
.export screen_setup_20x24
|
||||
|
||||
screen_setup_20x24:
|
||||
|
||||
; initialize SAVMSC
|
||||
lda #<SCREEN_BUF
|
||||
sta SAVMSC
|
||||
lda #>SCREEN_BUF
|
||||
sta SAVMSC+1
|
||||
|
||||
; initialize cursor position
|
||||
lda #0
|
||||
sta COLCRS_5200
|
||||
sta ROWCRS_5200
|
||||
|
||||
; clear screen buffer
|
||||
ldy #<(SCREEN_BUF_SIZE-1)
|
||||
ldx #>(SCREEN_BUF_SIZE-1)
|
||||
clrscr: sta (SAVMSC),y
|
||||
dey
|
||||
cpy #$FF
|
||||
bne clrscr
|
||||
dex
|
||||
cpx #$FF
|
||||
bne clrscr
|
||||
|
||||
; set display list
|
||||
|
||||
lda #<dlist
|
||||
sta SDLSTL
|
||||
lda #>dlist
|
||||
sta SDLSTH
|
||||
|
||||
rts
|
||||
|
||||
|
||||
.segment "RODATA"
|
||||
|
||||
; display list for 20x24 text mode
|
||||
|
||||
dlist: .repeat 3
|
||||
.byte DL_BLK8
|
||||
.endrepeat
|
||||
|
||||
.byte DL_CHR20x8x2 | DL_LMS
|
||||
.word SCREEN_BUF
|
||||
|
||||
.repeat 23
|
||||
.byte DL_CHR20x8x2
|
||||
.endrepeat
|
||||
|
||||
.byte DL_JVB
|
||||
.word dlist
|
||||
|
||||
; end of display list
|
||||
|
||||
.assert ((* >> 10) = (dlist >> 10)), error, "Display list crosses 1K boundary"
|
||||
|
||||
|
||||
.end
|
95
libsrc/atari5200/cputc.s
Normal file
95
libsrc/atari5200/cputc.s
Normal file
@ -0,0 +1,95 @@
|
||||
;
|
||||
; adapted from Atari version
|
||||
; Christian Groessler, 2014
|
||||
;
|
||||
; void cputcxy (unsigned char x, unsigned char y, char c);
|
||||
; void cputc (char c);
|
||||
;
|
||||
|
||||
.include "atari5200.inc"
|
||||
|
||||
.export _cputcxy, _cputc
|
||||
.export plot, cputdirect, putchar
|
||||
.import popa, _gotoxy, mul20
|
||||
.importzp ptr4
|
||||
.import setcursor
|
||||
|
||||
.constructor screen_setup, 26
|
||||
.import screen_setup_20x24
|
||||
screen_setup = screen_setup_20x24
|
||||
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
|
||||
_cputc:
|
||||
cmp #$0D ; CR
|
||||
bne L4
|
||||
lda #0
|
||||
sta COLCRS_5200
|
||||
beq plot ; return
|
||||
|
||||
L4: cmp #$0A ; LF
|
||||
beq newline
|
||||
cmp #ATEOL ; Atari-EOL?
|
||||
beq newline
|
||||
|
||||
tay
|
||||
rol a
|
||||
rol a
|
||||
rol a
|
||||
rol a
|
||||
and #3
|
||||
tax
|
||||
tya
|
||||
and #$9f
|
||||
ora ataint,x
|
||||
|
||||
cputdirect: ; accepts screen code
|
||||
jsr putchar
|
||||
|
||||
; advance cursor
|
||||
inc COLCRS_5200
|
||||
lda COLCRS_5200
|
||||
cmp #40
|
||||
bcc plot
|
||||
lda #0
|
||||
sta COLCRS_5200
|
||||
|
||||
.export newline
|
||||
newline:
|
||||
inc ROWCRS_5200
|
||||
lda ROWCRS_5200
|
||||
cmp #24
|
||||
bne plot
|
||||
lda #0
|
||||
sta ROWCRS_5200
|
||||
plot: jsr setcursor
|
||||
ldy COLCRS_5200
|
||||
ldx ROWCRS_5200
|
||||
rts
|
||||
|
||||
; turn off cursor, update screen, turn on cursor
|
||||
putchar:
|
||||
pha ; save char
|
||||
|
||||
lda ROWCRS_5200
|
||||
jsr mul20 ; destroys tmp4
|
||||
clc
|
||||
adc SAVMSC ; add start of screen memory
|
||||
sta ptr4
|
||||
txa
|
||||
adc SAVMSC+1
|
||||
sta ptr4+1
|
||||
pla ; get char again
|
||||
|
||||
ldy COLCRS_5200
|
||||
sta (ptr4),y
|
||||
jmp setcursor
|
||||
|
||||
.rodata
|
||||
ataint: .byte 64,0,32,96
|
||||
|
@ -1,7 +1,7 @@
|
||||
;
|
||||
; Startup code for cc65 (Atari5200 version)
|
||||
;
|
||||
; by Christian Groessler (chris@groessler.org), 2014
|
||||
; Christian Groessler (chris@groessler.org), 2014
|
||||
;
|
||||
|
||||
.export _exit, start
|
||||
@ -15,12 +15,6 @@
|
||||
.include "zeropage.inc"
|
||||
.include "atari5200.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Place the startup code in a special segment.
|
||||
|
||||
.segment "STARTUP"
|
||||
|
||||
start:
|
||||
|
||||
; Clear the BSS data
|
||||
@ -49,7 +43,6 @@ start:
|
||||
|
||||
_exit: jsr donelib ; Run module destructors
|
||||
|
||||
; Reset the NES
|
||||
|
||||
jmp start
|
||||
; A 5200 program isn't supposed to exit.
|
||||
|
||||
halt: jmp halt
|
||||
|
33
libsrc/atari5200/mul20.s
Normal file
33
libsrc/atari5200/mul20.s
Normal file
@ -0,0 +1,33 @@
|
||||
;
|
||||
; Christian Groessler, April 2014
|
||||
;
|
||||
; mul20
|
||||
; multiplies A by 20 and returns result in AX
|
||||
; uses tmp4
|
||||
|
||||
.importzp tmp4
|
||||
.export mul20,loc_tmp
|
||||
|
||||
.proc mul20
|
||||
|
||||
ldx #0
|
||||
stx tmp4
|
||||
sta loc_tmp
|
||||
asl a
|
||||
rol tmp4
|
||||
asl a
|
||||
rol tmp4 ; val * 4
|
||||
adc loc_tmp
|
||||
bcc L1
|
||||
inc tmp4 ; val * 5
|
||||
L1: asl a
|
||||
rol tmp4 ; val * 10
|
||||
asl a
|
||||
rol tmp4 ; val * 20
|
||||
ldx tmp4
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
.bss
|
||||
loc_tmp:.res 1
|
49
libsrc/atari5200/setcursor.s
Normal file
49
libsrc/atari5200/setcursor.s
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
|
||||
.include "atari5200.inc"
|
||||
.export setcursor
|
||||
.import cursor ; from conio/_cursor.s
|
||||
|
||||
|
||||
|
||||
.proc setcursor
|
||||
|
||||
rts
|
||||
|
||||
.if 0
|
||||
ldy #0
|
||||
|
||||
lda ROWCRS_5200
|
||||
jsr mul20
|
||||
clc
|
||||
; adc SAVMSC ; add start of screen memory
|
||||
; sta OLDADR
|
||||
txa
|
||||
; adc SAVMSC+1
|
||||
; sta OLDADR+1
|
||||
lda COLCRS_5200
|
||||
; adc OLDADR
|
||||
; sta OLDADR
|
||||
bcc nc
|
||||
; inc OLDADR+1
|
||||
nc:;;; lda (OLDADR),y
|
||||
; sta OLDCHR
|
||||
|
||||
ldx cursor ; current cursor setting as requested by the user
|
||||
beq off
|
||||
ldx #0
|
||||
beq cont
|
||||
|
||||
off: inx
|
||||
cont:;;; stx CRSINH ; update system variable
|
||||
|
||||
beq turnon
|
||||
and #$7f ; clear high bit / inverse flag
|
||||
finish: ;;;sta (OLDADR),y ; update on-screen display
|
||||
rts
|
||||
|
||||
turnon: ora #$80 ; set high bit / inverse flag
|
||||
bne finish
|
||||
.endif
|
||||
|
||||
.endproc
|
Loading…
Reference in New Issue
Block a user