Merge branch 'master' into missing-purple

This commit is contained in:
Bob Andrews
2022-05-17 15:34:51 +02:00
committed by GitHub
697 changed files with 12785 additions and 3271 deletions

View File

@@ -21,6 +21,7 @@ TARGETS = apple2 \
atarixl \
atari2600 \
atari5200 \
atari7800 \
atmos \
creativision \
$(CBMS) \
@@ -95,7 +96,6 @@ INSTALL = install
define INSTALL_recipe
$(if $(PREFIX),,$(error variable "PREFIX" must be set))
$(INSTALL) -d $(DESTDIR)$(datadir)/$(dir)
$(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir)

View File

@@ -13,4 +13,4 @@ _textcolor := return1
_bgcolor := return0
_bordercolor := return0
_bordercolor := return0

View File

@@ -18,7 +18,7 @@ typerr: lda #$4A ; "Incompatible file format"
; Cleanup name
oserr: jsr popname ; Preserves A
; Set __oserror
jmp __mappederrno
@@ -129,7 +129,7 @@ setbuf: lda #$00 ; Low byte
.assert MLI::OPEN::PATHNAME = MLI::INFO::PATHNAME, error
; Lower file level to avoid program file
; being closed by C libary shutdown code
; being closed by C library shutdown code
ldx LEVEL
stx level
beq :+
@@ -185,13 +185,13 @@ setbuf: lda #$00 ; Low byte
lda #$00 ; '\0'
beq :- ; Branch always
; Call loader stub after C libary shutdown
; Call loader stub after C library shutdown
: lda #<target
ldx #>target
sta done+1
stx done+2
; Initiate C libary shutdown
; Initiate C library shutdown
jmp _exit
.bss

View File

@@ -2,7 +2,7 @@
; Oliver Schmidt, 10.9.2009
;
; Default ProDOS 8 I/O buffer management
;
;
.export iobuf_alloc, iobuf_free
.import _posix_memalign, _free

View File

@@ -8,13 +8,13 @@
;
.export _mouse_def_callbacks
.include "apple2.inc"
; ------------------------------------------------------------------------
.bss
backup: .res 1
visible:.res 1

View File

@@ -152,7 +152,7 @@ next: inc ptr1+1
sta xparam+1
sta jump+2
; Disable interrupts now because setting the slot number makes
; Disable interrupts now because setting the slot number makes
; the IRQ handler (maybe called due to some non-mouse IRQ) try
; calling the firmware which isn't correctly set up yet
sei
@@ -167,7 +167,7 @@ next: inc ptr1+1
asl
asl
sta yparam+1
; The AppleMouse II Card needs the ROM switched in
; to be able to detect an Apple //e and use RDVBL
bit $C082
@@ -175,7 +175,7 @@ next: inc ptr1+1
; Reset mouse hardware
ldx #INITMOUSE
jsr firmware
; Switch in LC bank 2 for R/O
bit $C080
@@ -236,12 +236,12 @@ UNINSTALL:
SETBOX:
sta ptr1
stx ptr1+1
; Set x clamps
ldx #$00
ldy #MOUSE_BOX::MINX
jsr :+
; Set y clamps
ldx #$01
ldy #MOUSE_BOX::MINY
@@ -257,7 +257,7 @@ SETBOX:
sta pos1_lo
iny
lda (ptr1),y
sta box,y
sta box,y
sta pos1_hi
; Skip one word
@@ -267,11 +267,11 @@ SETBOX:
; Set high clamp
iny
lda (ptr1),y
sta box,y
sta box,y
sta pos2_lo
iny
lda (ptr1),y
sta box,y
sta box,y
sta pos2_hi
txa

View File

@@ -57,7 +57,7 @@ extern char _cwd[FILENAME_MAX];
DIR* __fastcall__ opendir (register const char* name)
DIR* __fastcall__ opendir (register const char* name)
{
register DIR* dir;

View File

@@ -111,4 +111,4 @@ errno: jmp __directerrno
; Set __oserror
oserr: jmp __mappederrno

View File

@@ -63,7 +63,7 @@ L1: lda #<brk_handler ; Set the break vector to our routine
lda #$00
sta oldvec ; Clear the old vector
stx oldvec+1
@L9: rts
@L9: rts
.endproc

View File

@@ -17,7 +17,7 @@ _cclearxy:
_cclear:
cmp #0 ; Is the length zero?
beq L9 ; Jump if done
sta tmp1
sta tmp1
L1: lda #0 ; Blank - screen code
jsr cputdirect ; Direct output
dec tmp1

View File

@@ -12,7 +12,7 @@
.include "ctypetable.inc"
.export __ctypeidx
; The tables are readonly, put them into the rodata segment
.rodata

View File

@@ -5,7 +5,7 @@
; void cvline (unsigned char length);
;
.include "atari.inc"
.export _cvlinexy, _cvline
.import gotoxy, putchar, setcursor
.importzp tmp1

View File

@@ -137,7 +137,7 @@ _dio_open:
iny
lda #1
finish: sta (ptr2),y ; set default sector size
finish: sta (ptr2),y ; set default sector size
fini2: lda ptr2
ldx ptr2+1
rts

View File

@@ -12,7 +12,7 @@
.proc _dio_query_sectsize
sta ptr1 ; handle
stx ptr1+1
stx ptr1+1
lda #0
sta __oserror

View File

@@ -12,7 +12,7 @@
.ifdef __ATARIXL__
_doesclrscrafterexit = return1 ; the c65 runtime always clears the screen at program termination
.else
.else
_doesclrscrafterexit:
jsr __is_cmdline_dos ; currently (unless a DOS behaving differently is popping up)
eor #$01 ; we can get by with the inverse of __is_cmdline_dos

View File

@@ -11,7 +11,7 @@
; Bit 2: bank control
; Bit 1: BASIC on/off
; Bit 0: OS RAM on/off
;
;
; Masks: %11100011 $E3 Bank 0
; %11100111 $E7 Bank 1
; %11101011 $EB Bank 2
@@ -67,7 +67,7 @@
; Constants
BANK = $4000 ; bank window
STACK = $0100 ; stack location
STACK = $0100 ; stack location
PAGES = 256 ; 4 x 16k banks
@@ -93,17 +93,17 @@ stacktest: sei
@2: sta $4000 ; restore
cli
rts
stacktest_end:
stacktest_end:
stackcopy: sei ; disable interrupts
@1: dex ; pre-decrement (full page x=0)
ldy #$FF ; this will be replaced STACK+3
sty $D301 ; set bank
sty $D301 ; set bank
lda $FF00,x ; address to copy from STACK+8,+9
ldy #$FF ; this will be replaced STACK+11
sty $D301
sty $D301
sta $FF00,x ; address to copy to STACK+16,+17
cpx #0
cpx #0
bne @1
ldy #$FF ; portb_save STACK+23
sty $D301
@@ -122,7 +122,7 @@ stackcopy_byte: sei
sty $D301
cli
rts
stackcopy_byte_end:
stackcopy_byte_end:
.data
@@ -186,14 +186,14 @@ setpage:
INSTALL:
lda $D301 ; save state of portb
sta portb_save
tay
tay
jsr install_test ; doesn't touch Y
sty STACK+13
lda $4000 ; test for extended memory
jsr STACK
bcs @1
bcs @1
lda #EM_ERR_OK
rts
@1: lda #EM_ERR_NO_DEVICE
@@ -242,7 +242,7 @@ MAP: jsr setpage ; extract the bank/page
lda banks,x
sta STACK+3 ; set bank to copy from
; lda ptr1
; sta STACK+8
; sta STACK+8
lda ptr1+1
sta STACK+9 ; set copy from address
lda portb_save
@@ -251,10 +251,10 @@ MAP: jsr setpage ; extract the bank/page
lda ptr2
sta STACK+16
lda ptr2+1
sta STACK+17 ; set copy to address
sta STACK+17 ; set copy to address
ldx #0 ; full page copy
jsr STACK ; do the copy!
jsr STACK ; do the copy!
; Return the memory window
@@ -298,7 +298,7 @@ COMMIT: lda curpage ; Get the current page
sta STACK+3 ; set bank to copy from
sta STACK+23 ; set final portb restore
lda ptr1
sta STACK+8
sta STACK+8
lda ptr1+1
sta STACK+9 ; set copy from address
ldx curbank
@@ -307,10 +307,10 @@ COMMIT: lda curpage ; Get the current page
;lda ptr2
;sta STACK+16
lda ptr2+1
sta STACK+17 ; set copy to address
sta STACK+17 ; set copy to address
ldx #0 ; full page copy
jsr STACK ; do the copy!
jsr STACK ; do the copy!
commit_done:
rts
@@ -329,7 +329,7 @@ COPYFROM:
ldy #EM_COPY::OFFS
lda (ptr3),y
sta STACK+7 ; offset goes into BANK low
sta STACK+7 ; offset goes into BANK low
ldy #EM_COPY::PAGE
lda (ptr3),y
@@ -357,9 +357,9 @@ COPYFROM:
add #>BANK ; add to BANK address
sta STACK+8 ; current page in bank
ldx curbank
lda banks,x
sta STACK+2 ; set bank in stack
lda portb_save
lda banks,x
sta STACK+2 ; set bank in stack
lda portb_save
sta STACK+10 ; set bank restore in stack
sta STACK+18 ; set final restore too
@@ -399,7 +399,7 @@ copyfrom_copy:
bne @3
inc STACK+16
@3: jmp copyfrom_copy ; copy another byte
@3: jmp copyfrom_copy ; copy another byte
done:
rts
@@ -418,7 +418,7 @@ COPYTO:
ldy #EM_COPY::OFFS
lda (ptr3),y
sta STACK+15 ; offset goes into BANK low
sta STACK+15 ; offset goes into BANK low
ldy #EM_COPY::PAGE
lda (ptr3),y
@@ -446,9 +446,9 @@ COPYTO:
add #>BANK ; add to BANK address
sta STACK+16 ; current page in bank
ldx curbank
lda banks,x
sta STACK+10 ; set bank in stack
lda portb_save
lda banks,x
sta STACK+10 ; set bank in stack
lda portb_save
sta STACK+2 ; set bank restore in stack
sta STACK+18 ; set final restore too
@@ -488,5 +488,5 @@ copyto_copy:
bne @3
inc STACK+8
@3: jmp copyto_copy ; copy another byte
@3: jmp copyto_copy ; copy another byte

View File

@@ -74,7 +74,7 @@ prep:
jsr getcursor ; Get character at cursor position
cmp #mouse_txt_char ; "mouse" character
bne overwr ; no, probably program has overwritten it
lda backup ;
lda backup ;
jmp setcursor ; Draw character
overwr: sta backup
rts

View File

@@ -10,7 +10,7 @@
.include "atari.inc"
__randomize:
__randomize:
ldx VCOUNT ; Use vertical line counter as high byte
lda RTCLOK+2 ; Use clock as low byte
jmp _srand ; Initialize generator

View File

@@ -4,7 +4,7 @@
; unsigned char revers (unsigned char onoff);
;
.include "atari.inc"
.export _revers
.export _revflag

View File

@@ -737,9 +737,9 @@ fn_cont:jsr get_fn_len
lda #0
sta ICBLH,x
jsr chk_CIO_buf
pla
pla
sta ICBLH,x
pla
pla
sta ICBLL,x
pla
tay
@@ -756,7 +756,7 @@ chk_CIO_buf:
lda ICBAH,x
cmp #$c0
bcc @cont
@ret:
@ret:
.ifdef DEBUG
jsr CIO_buf_noti
.endif

View File

@@ -93,7 +93,7 @@ sdnobw: lda DOS+1 ; SD version
ldy #31 ; offset for OSRMFLG
lda (DOSVEC),y ; get OSRMFLG
bne sdcrts1
sdcrts0:clc
rts
sdcrts1:sec

View File

@@ -7,7 +7,7 @@
; It calculates the value to put into RAMTOP for a subsequent
; "GRAPHICS 0" call, and the lowest address which will be used
; by the screen memory afterwards.
;
;
; inputs:
; __STARTADDRESS__ - load address of the program
; outputs:

View File

@@ -74,7 +74,7 @@ conio_color: .res 1
dlist: .repeat 3
.byte DL_BLK8
.endrepeat
.byte DL_CHR20x8x2 | DL_LMS
.word SCREEN_BUF

View File

@@ -5,7 +5,7 @@
; void cvline (unsigned char length);
;
.include "atari5200.inc"
.export _cvlinexy, _cvline
.import gotoxy, putchar
.importzp tmp1

View File

@@ -74,7 +74,7 @@ conio_color: .res 1
dlist: .repeat 3
.byte DL_BLK8
.endrepeat
.byte DL_CHR20x16x2 | DL_LMS
.word SCREEN_BUF

View File

@@ -44,7 +44,7 @@
;
INSTALL:
lda #$04 ; enable POT input from the joystick ports, see section "GTIA" in
lda #$04 ; enable POT input from the joystick ports, see section "GTIA" in
sta CONSOL ; http://www.atarimuseum.com/videogames/consoles/5200/conv_to_5200.html
lda #JOY_ERR_OK
ldx #0

View File

@@ -10,7 +10,7 @@
.include "atari5200.inc"
__randomize:
__randomize:
ldx VCOUNT ; Use vertical line counter as high byte
lda RTCLOK+1 ; Use clock as low byte
jmp _srand ; Initialize generator

View File

@@ -9,16 +9,16 @@ Y2K LDY #$00 ; Copy BIOS opening screen to RAM
CPX #$E8 ; Is this a 4 port?
BNE Y2K0 ; Jump if not
LDA #$42 ; Yes, 4 port system
Y2K0 STA TEMPL
Y2K1 LDA (TEMPL),Y
Y2K0 STA TEMPL
Y2K1 LDA (TEMPL),Y
STA $0600,Y
INY
INY
BNE Y2K1
LDY #$50
INC TEMPH
Y2K2 LDA (TEMPL),Y
Y2K2 LDA (TEMPL),Y
STA $0700,Y
DEY
DEY
BPL Y2K2
LDA #$D4 ; Point to copyright string
STA $0724
@@ -26,8 +26,8 @@ Y2K2 LDA (TEMPL),Y
STA $0725
LDX #$0B ; Store NOP's @ end
LDA #$EA
Y2K3 STA $0732,X
DEX
Y2K3 STA $0732,X
DEX
BPL Y2K3
LDA #$60 ; Store RTS opcode @ end
STA $0750

69
libsrc/atari7800/clock.s Normal file
View File

@@ -0,0 +1,69 @@
;
; 2022-03-15, Karri Kaksonen
;
; clock_t clock (void);
;
.export _clock, clock_count
.interruptor update_clock, 2 ; (low priority)
.constructor init_clock
.import sreg: zp
.import _zonecounter
.include "atari7800.inc"
.macpack generic
.code
;-----------------------------------------------------------------------------
; Read the clock counter.
;
.proc _clock
lda #0
sta sreg+1 ; Promote 24 bits up to 32 bits
lda clock_count+2
sta sreg
ldx clock_count+1
lda clock_count
rts
.endproc
;-----------------------------------------------------------------------------
; This interrupt handler increments a 24-bit counter at every video
; vertical-blanking time.
; Update the clock only on interrupt while the drawing on screen is on
; _zonecounter == 1 (from 1st visible scanline to last visible scanline)
;
update_clock:
lda _zonecounter
and #01
beq @L1
inc clock_count
bne @L1
inc clock_count+1
bne @L1
inc clock_count+2
@L1: ;clc ; General interrupt was not reset
rts
;-----------------------------------------------------------------------------
; Set time to zero at startup
;
.segment "ONCE"
init_clock:
lda #0
sta clock_count+2
sta clock_count+1
sta clock_count
rts
;-----------------------------------------------------------------------------
; Store time in 3 bytes
;
.bss
clock_count:
.res 3

View File

@@ -0,0 +1,34 @@
;
; 2022-03-15, Karri Kaksonen
;
; clock_t _clocks_per_sec (void);
;
.export __clocks_per_sec
.import sreg: zp
.import _paldetected
.include "atari7800.inc"
.macpack generic
.code
;-----------------------------------------------------------------------------
; Return the number of clock ticks in one second.
;
.proc __clocks_per_sec
lda #0
tax
sta sreg ; return 32 bits
sta sreg+1
lda _paldetected
bne pal
lda #60 ; NTSC - 60Hz
rts
pal:
lda #50 ; PAL - 50Hz
rts
.endproc

27
libsrc/atari7800/clrscr.s Normal file
View File

@@ -0,0 +1,27 @@
.include "atari7800.inc"
.export _clrscr
.import _screen
.import pushax, __bzero
.include "extzp.inc"
.code
.proc _clrscr
lda #<_screen
ldx #>_screen
jsr pushax
ldx #>(charsperline * screenrows)
lda #<(charsperline * screenrows)
jmp __bzero
.endproc
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

226
libsrc/atari7800/conio.s Normal file
View File

@@ -0,0 +1,226 @@
;
; 2022-04-02, Karri Kaksonen
;
; The Atari 7800 has only 4k of RAM. So for a generic conio implementation
; the best alternative is to use indirect tile mapping with a character
; frame buffer
;
.constructor initconio
.include "atari7800.inc"
.include "extzp.inc"
.import _conio_font
.import _get_tv
.export _screen
.export _zones
.export _dll
.bss
_screen:
.res charsperline * screenrows
;----------------------------------------------------------------------------
; Macros used to generate lists
.macro DLLentry offset, addr
.byte offset
.byte >addr
.byte <addr
.endmacro
.macro NullHeader offset, zero
.byte offset
.byte zero
.endmacro
.macro Header addr, palwidth, hpos
.byte <addr
.byte palwidth
.byte >addr
.byte hpos
.endmacro
.macro XHeader addr, flags, palwidth, hpos
.byte <addr
.byte flags
.byte >addr
.byte palwidth
.byte hpos
.endmacro
.macro TextZone row
; Text
.byte <(_screen + row * charsperline)
.byte $60
.byte >(_screen + row * charsperline)
.byte 12
.byte 0
; Cursor
.byte 254
.byte 0
.byte >_conio_font
.byte 0
.endmacro
;-----------------------------------------------------------------------------
; The Atari 7800 has only 4k of RAM. So for a generic conio implementation
; the best alternative is to use indirect tile mapping with a character
; frame buffer
.data
_zones:
zone0: TextZone 0
nh: NullHeader 0, 0
zone1: TextZone 1
NullHeader 0, 0
zone2: TextZone 2
NullHeader 0, 0
zone3: TextZone 3
NullHeader 0, 0
zone4: TextZone 4
NullHeader 0, 0
zone5: TextZone 5
NullHeader 0, 0
zone6: TextZone 6
NullHeader 0, 0
zone7: TextZone 7
NullHeader 0, 0
zone8: TextZone 8
NullHeader 0, 0
zone9: TextZone 9
NullHeader 0, 0
zone10: TextZone 10
NullHeader 0, 0
zone11: TextZone 11
NullHeader 0, 0
zone12: TextZone 12
NullHeader 0, 0
zone13: TextZone 13
NullHeader 0, 0
zone14: TextZone 14
NullHeader 0, 0
zone15: TextZone 15
NullHeader 0, 0
zone16: TextZone 16
NullHeader 0, 0
zone17: TextZone 17
NullHeader 0, 0
zone18: TextZone 18
NullHeader 0, 0
zone19: TextZone 19
NullHeader 0, 0
zone20: TextZone 20
NullHeader 0, 0
zone21: TextZone 21
NullHeader 0, 0
zone22: TextZone 22
NullHeader 0, 0
zone23: TextZone 23
NullHeader 0, 0
zone24: TextZone 24
NullHeader 0, 0
zone25: TextZone 25
NullHeader 0, 0
zone26: TextZone 26
NullHeader 0, 0
zone27: TextZone 27
NullHeader 0, 0
_dll:
PALscanlines: ; 25 lines
DLLentry 15, nh
DLLentry 8, nh
Topscanlines: ; 9 lines
DLLentry 8, nh
Displaylines:
DLLentry $80+7, zone0 ; NMI interrupt from end of prev zone
DLLentry 7, zone1
DLLentry 7, zone2
DLLentry 7, zone3
DLLentry 7, zone4
DLLentry 7, zone5
DLLentry 7, zone6
DLLentry 7, zone7
DLLentry 7, zone8
DLLentry 7, zone9
DLLentry 7, zone10
DLLentry 7, zone11
DLLentry 7, zone12
DLLentry 7, zone13
DLLentry 7, zone14
DLLentry 7, zone15
DLLentry 7, zone16
DLLentry 7, zone17
DLLentry 7, zone18
DLLentry 7, zone19
DLLentry 7, zone20
DLLentry 7, zone21
DLLentry 7, zone22
DLLentry 7, zone23
DLLentry 7, zone24
DLLentry 7, zone25
DLLentry 7, zone26
DLLentry 7, zone27
Bottomscanlines:
DLLentry $80+15, nh ; NMI interrupt at end of display
DLLentry 9, nh
DLLentry 15, nh
DLLentry 8, nh
;-----------------------------------------------------------------------------
; Set up the screen to 320a mode
;
.segment "ONCE"
CTRL_MODE160 .set 0
CTRL_MODEAC .set 3
CTRL_KANGOFF .set 0
CTRL_BCBLACK .set 0
CTRL_CHAR1B .set 0
CTRL_CHAR2B .set $10
CTRL_DMAON .set $40
CTRL_CKOFF .set 0
;-----------------------------------------------------------------------------
; Initialize the conio display lists and zones
;
.proc initconio
jsr _get_tv
bne pal
lda #<Topscanlines
sta DPPL
lda #>Topscanlines
sta DPPH
jmp vblankon
pal: lda #<PALscanlines
sta DPPL
lda #>PALscanlines
sta DPPH
vblankon:
lda MSTAT
bmi vblankon
vblankoff:
lda MSTAT
bpl vblankoff
lda #>_conio_font
sta CHBASE
lda #(CTRL_MODE160 | CTRL_KANGOFF | CTRL_BCBLACK | CTRL_CHAR2B | CTRL_DMAON | CTRL_CKOFF)
sta CTRL
lda #$00 ; Black background
sta BKGRND
sta CURS_X
sta CURS_Y
lda #$33 ; Red
sta P0C1
lda #$c8 ; Green
sta P0C2
lda #$0f ; White
sta P0C3
rts
.endproc

View File

@@ -0,0 +1,278 @@
; The internal font structure for Atari7800 needs a full set of 128
; characters. Each character is 16 x 8 bits.
; The font consists of 8 rows of data:
; row7
; row6
; row5
; row4
; row3
; row2
; row1
; row0
; Each row is 256 bytes long
; As we have 2 bits per pixel we need 2 bytes to represent
; one character. So we can fit 128 characters in this font
; When you later use the font you must address the characters as
; 0, 2, 4, 6, ... 254
; Odd indices cannot be used.
.export _conio_font
.rodata
.align 256
_conio_font:
.byte $0, $0, $41, $41, $0, $0, $14, $0
.byte $0, $0, $0, $0, $1, $40, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $82, $82
.byte $0, $0, $28, $0, $0, $0, $0, $0
.byte $2, $80, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $c3, $c3, $0, $0, $3c, $0
.byte $0, $0, $0, $0, $3, $c0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $0, $0
.byte $0, $0, $0, $0, $0, $0, $ff, $ff
.byte $0, $0, $11, $44, $5, $0, $5, $0
.byte $0, $0, $5, $0, $1, $40, $15, $50
.byte $55, $50, $55, $50, $15, $40, $1, $54
.byte $15, $40, $15, $40, $5, $0, $15, $40
.byte $15, $0, $50, $50, $55, $50, $5, $50
.byte $55, $40, $55, $54, $55, $0, $5, $54
.byte $50, $50, $15, $40, $15, $40, $54, $14
.byte $55, $54, $50, $14, $50, $14, $5, $40
.byte $55, $0, $1, $50, $54, $14, $15, $40
.byte $15, $40, $55, $50, $5, $0, $50, $14
.byte $50, $14, $15, $40, $55, $54, $22, $88
.byte $a, $0, $a, $0, $0, $0, $a, $0
.byte $2, $80, $2a, $a0, $aa, $a0, $aa, $a0
.byte $2a, $80, $2, $a8, $2a, $80, $2a, $80
.byte $a, $0, $2a, $80, $2a, $0, $a0, $a0
.byte $aa, $a0, $a, $a0, $aa, $80, $aa, $a8
.byte $aa, $0, $a, $a8, $a0, $a0, $2a, $80
.byte $2a, $80, $a8, $28, $aa, $a8, $a0, $28
.byte $a0, $28, $a, $80, $aa, $0, $2, $a0
.byte $a8, $28, $2a, $80, $2a, $80, $aa, $a0
.byte $a, $0, $a0, $28, $a0, $28, $2a, $80
.byte $aa, $a8, $33, $cc, $f, $0, $f, $0
.byte $0, $0, $f, $0, $3, $c0, $3f, $f0
.byte $ff, $f0, $ff, $f0, $3f, $c0, $3, $fc
.byte $3f, $c0, $3f, $c0, $f, $0, $3f, $c0
.byte $3f, $0, $f0, $f0, $ff, $f0, $f, $f0
.byte $ff, $c0, $ff, $fc, $ff, $0, $f, $fc
.byte $f0, $f0, $3f, $c0, $3f, $c0, $fc, $3c
.byte $ff, $fc, $f0, $3c, $f0, $3c, $f, $c0
.byte $ff, $0, $3, $f0, $fc, $3c, $3f, $c0
.byte $3f, $c0, $ff, $f0, $f, $0, $f0, $3c
.byte $f0, $3c, $3f, $c0, $ff, $fc, $0, $0
.byte $0, $0, $5, $50, $0, $0, $5, $0
.byte $0, $0, $5, $0, $1, $40, $54, $14
.byte $5, $0, $50, $50, $50, $50, $0, $50
.byte $50, $50, $50, $50, $5, $0, $50, $50
.byte $1, $40, $50, $50, $14, $14, $14, $14
.byte $14, $50, $14, $4, $14, $0, $14, $14
.byte $50, $50, $5, $0, $50, $50, $14, $14
.byte $14, $14, $50, $14, $50, $14, $14, $50
.byte $14, $0, $15, $40, $14, $14, $50, $50
.byte $5, $0, $50, $50, $15, $40, $54, $54
.byte $14, $50, $5, $0, $14, $14, $a, $a0
.byte $0, $0, $a, $0, $0, $0, $a, $0
.byte $2, $80, $a8, $28, $a, $0, $a0, $a0
.byte $a0, $a0, $0, $a0, $a0, $a0, $a0, $a0
.byte $a, $0, $a0, $a0, $2, $80, $a0, $a0
.byte $28, $28, $28, $28, $28, $a0, $28, $8
.byte $28, $0, $28, $28, $a0, $a0, $a, $0
.byte $a0, $a0, $28, $28, $28, $28, $a0, $28
.byte $a0, $28, $28, $a0, $28, $0, $2a, $80
.byte $28, $28, $a0, $a0, $a, $0, $a0, $a0
.byte $2a, $80, $a8, $a8, $28, $a0, $a, $0
.byte $28, $28, $f, $f0, $0, $0, $f, $0
.byte $0, $0, $f, $0, $3, $c0, $fc, $3c
.byte $f, $0, $f0, $f0, $f0, $f0, $0, $f0
.byte $f0, $f0, $f0, $f0, $f, $0, $f0, $f0
.byte $3, $c0, $f0, $f0, $3c, $3c, $3c, $3c
.byte $3c, $f0, $3c, $c, $3c, $0, $3c, $3c
.byte $f0, $f0, $f, $0, $f0, $f0, $3c, $3c
.byte $3c, $3c, $f0, $3c, $f0, $3c, $3c, $f0
.byte $3c, $0, $3f, $c0, $3c, $3c, $f0, $f0
.byte $f, $0, $f0, $f0, $3f, $c0, $fc, $fc
.byte $3c, $f0, $f, $0, $3c, $3c, $0, $0
.byte $0, $0, $54, $15, $5, $0, $0, $0
.byte $55, $55, $0, $0, $1, $40, $55, $14
.byte $5, $0, $14, $0, $0, $50, $55, $54
.byte $0, $50, $50, $50, $5, $0, $50, $50
.byte $0, $50, $55, $50, $14, $14, $50, $0
.byte $14, $14, $14, $40, $14, $40, $50, $54
.byte $50, $50, $5, $0, $50, $50, $14, $50
.byte $14, $4, $51, $14, $50, $54, $50, $14
.byte $14, $0, $51, $50, $14, $50, $1, $50
.byte $5, $0, $50, $50, $50, $50, $55, $54
.byte $5, $40, $5, $0, $5, $4, $a8, $2a
.byte $a, $0, $0, $0, $aa, $aa, $0, $0
.byte $2, $80, $aa, $28, $a, $0, $28, $0
.byte $0, $a0, $aa, $a8, $0, $a0, $a0, $a0
.byte $a, $0, $a0, $a0, $0, $a0, $aa, $a0
.byte $28, $28, $a0, $0, $28, $28, $28, $80
.byte $28, $80, $a0, $a8, $a0, $a0, $a, $0
.byte $a0, $a0, $28, $a0, $28, $8, $a2, $28
.byte $a0, $a8, $a0, $28, $28, $0, $a2, $a0
.byte $28, $a0, $2, $a0, $a, $0, $a0, $a0
.byte $a0, $a0, $aa, $a8, $a, $80, $a, $0
.byte $a, $8, $fc, $3f, $f, $0, $0, $0
.byte $ff, $ff, $0, $0, $3, $c0, $ff, $3c
.byte $f, $0, $3c, $0, $0, $f0, $ff, $fc
.byte $0, $f0, $f0, $f0, $f, $0, $f0, $f0
.byte $0, $f0, $ff, $f0, $3c, $3c, $f0, $0
.byte $3c, $3c, $3c, $c0, $3c, $c0, $f0, $fc
.byte $f0, $f0, $f, $0, $f0, $f0, $3c, $f0
.byte $3c, $c, $f3, $3c, $f0, $fc, $f0, $3c
.byte $3c, $0, $f3, $f0, $3c, $f0, $3, $f0
.byte $f, $0, $f0, $f0, $f0, $f0, $ff, $fc
.byte $f, $c0, $f, $0, $f, $c, $0, $0
.byte $0, $0, $54, $15, $1, $40, $0, $0
.byte $55, $55, $0, $0, $1, $40, $51, $54
.byte $5, $0, $5, $40, $5, $40, $50, $50
.byte $0, $50, $55, $40, $1, $40, $15, $40
.byte $15, $50, $50, $50, $15, $50, $50, $0
.byte $14, $14, $15, $40, $15, $40, $50, $0
.byte $55, $50, $5, $0, $0, $50, $15, $40
.byte $14, $0, $55, $54, $51, $54, $50, $14
.byte $15, $50, $50, $50, $15, $50, $15, $0
.byte $5, $0, $50, $50, $50, $50, $51, $14
.byte $5, $40, $15, $40, $1, $40, $a8, $2a
.byte $2, $80, $0, $0, $aa, $aa, $0, $0
.byte $2, $80, $a2, $a8, $a, $0, $a, $80
.byte $a, $80, $a0, $a0, $0, $a0, $aa, $80
.byte $2, $80, $2a, $80, $2a, $a0, $a0, $a0
.byte $2a, $a0, $a0, $0, $28, $28, $2a, $80
.byte $2a, $80, $a0, $0, $aa, $a0, $a, $0
.byte $0, $a0, $2a, $80, $28, $0, $aa, $a8
.byte $a2, $a8, $a0, $28, $2a, $a0, $a0, $a0
.byte $2a, $a0, $2a, $0, $a, $0, $a0, $a0
.byte $a0, $a0, $a2, $28, $a, $80, $2a, $80
.byte $2, $80, $fc, $3f, $3, $c0, $0, $0
.byte $ff, $ff, $0, $0, $3, $c0, $f3, $fc
.byte $f, $0, $f, $c0, $f, $c0, $f0, $f0
.byte $0, $f0, $ff, $c0, $3, $c0, $3f, $c0
.byte $3f, $f0, $f0, $f0, $3f, $f0, $f0, $0
.byte $3c, $3c, $3f, $c0, $3f, $c0, $f0, $0
.byte $ff, $f0, $f, $0, $0, $f0, $3f, $c0
.byte $3c, $0, $ff, $fc, $f3, $fc, $f0, $3c
.byte $3f, $f0, $f0, $f0, $3f, $f0, $3f, $0
.byte $f, $0, $f0, $f0, $f0, $f0, $f3, $3c
.byte $f, $c0, $3f, $c0, $3, $c0, $0, $0
.byte $0, $0, $5, $50, $0, $50, $0, $0
.byte $0, $0, $0, $0, $1, $40, $50, $54
.byte $5, $0, $0, $50, $0, $50, $14, $50
.byte $55, $40, $50, $0, $0, $50, $50, $50
.byte $50, $50, $50, $50, $14, $14, $50, $0
.byte $14, $14, $14, $40, $14, $40, $50, $0
.byte $50, $50, $5, $0, $0, $50, $14, $50
.byte $14, $0, $55, $54, $55, $14, $50, $14
.byte $14, $14, $50, $50, $14, $14, $54, $0
.byte $5, $0, $50, $50, $50, $50, $50, $14
.byte $14, $50, $50, $50, $40, $50, $a, $a0
.byte $0, $a0, $0, $0, $0, $0, $0, $0
.byte $2, $80, $a0, $a8, $a, $0, $0, $a0
.byte $0, $a0, $28, $a0, $aa, $80, $a0, $0
.byte $0, $a0, $a0, $a0, $a0, $a0, $a0, $a0
.byte $28, $28, $a0, $0, $28, $28, $28, $80
.byte $28, $80, $a0, $0, $a0, $a0, $a, $0
.byte $0, $a0, $28, $a0, $28, $0, $aa, $a8
.byte $aa, $28, $a0, $28, $28, $28, $a0, $a0
.byte $28, $28, $a8, $0, $a, $0, $a0, $a0
.byte $a0, $a0, $a0, $28, $28, $a0, $a0, $a0
.byte $80, $a0, $f, $f0, $0, $f0, $0, $0
.byte $0, $0, $0, $0, $3, $c0, $f0, $fc
.byte $f, $0, $0, $f0, $0, $f0, $3c, $f0
.byte $ff, $c0, $f0, $0, $0, $f0, $f0, $f0
.byte $f0, $f0, $f0, $f0, $3c, $3c, $f0, $0
.byte $3c, $3c, $3c, $c0, $3c, $c0, $f0, $0
.byte $f0, $f0, $f, $0, $0, $f0, $3c, $f0
.byte $3c, $0, $ff, $fc, $ff, $3c, $f0, $3c
.byte $3c, $3c, $f0, $f0, $3c, $3c, $fc, $0
.byte $f, $0, $f0, $f0, $f0, $f0, $f0, $3c
.byte $3c, $f0, $f0, $f0, $c0, $f0, $0, $0
.byte $0, $0, $11, $44, $50, $50, $0, $0
.byte $0, $0, $0, $0, $1, $40, $50, $14
.byte $15, $0, $50, $50, $50, $50, $5, $50
.byte $50, $0, $14, $0, $50, $50, $50, $50
.byte $50, $50, $15, $40, $14, $14, $14, $14
.byte $14, $50, $14, $4, $14, $4, $14, $14
.byte $50, $50, $5, $0, $0, $50, $14, $14
.byte $14, $0, $54, $54, $54, $14, $14, $50
.byte $14, $14, $50, $50, $14, $14, $50, $50
.byte $45, $10, $50, $50, $50, $50, $50, $14
.byte $50, $14, $50, $50, $50, $14, $22, $88
.byte $a0, $a0, $0, $0, $0, $0, $0, $0
.byte $2, $80, $a0, $28, $2a, $0, $a0, $a0
.byte $a0, $a0, $a, $a0, $a0, $0, $28, $0
.byte $a0, $a0, $a0, $a0, $a0, $a0, $2a, $80
.byte $28, $28, $28, $28, $28, $a0, $28, $8
.byte $28, $8, $28, $28, $a0, $a0, $a, $0
.byte $0, $a0, $28, $28, $28, $0, $a8, $a8
.byte $a8, $28, $28, $a0, $28, $28, $a0, $a0
.byte $28, $28, $a0, $a0, $8a, $20, $a0, $a0
.byte $a0, $a0, $a0, $28, $a0, $28, $a0, $a0
.byte $a0, $28, $33, $cc, $f0, $f0, $0, $0
.byte $0, $0, $0, $0, $3, $c0, $f0, $3c
.byte $3f, $0, $f0, $f0, $f0, $f0, $f, $f0
.byte $f0, $0, $3c, $0, $f0, $f0, $f0, $f0
.byte $f0, $f0, $3f, $c0, $3c, $3c, $3c, $3c
.byte $3c, $f0, $3c, $c, $3c, $c, $3c, $3c
.byte $f0, $f0, $f, $0, $0, $f0, $3c, $3c
.byte $3c, $0, $fc, $fc, $fc, $3c, $3c, $f0
.byte $3c, $3c, $f0, $f0, $3c, $3c, $f0, $f0
.byte $cf, $30, $f0, $f0, $f0, $f0, $f0, $3c
.byte $f0, $3c, $f0, $f0, $f0, $3c, $0, $0
.byte $0, $0, $41, $41, $15, $40, $0, $0
.byte $0, $0, $0, $0, $1, $40, $15, $50
.byte $5, $0, $15, $40, $15, $40, $1, $50
.byte $55, $50, $5, $40, $55, $50, $15, $40
.byte $15, $40, $5, $0, $55, $50, $5, $50
.byte $55, $40, $55, $54, $55, $54, $5, $50
.byte $50, $50, $15, $40, $1, $54, $54, $14
.byte $55, $0, $50, $14, $50, $14, $5, $40
.byte $55, $50, $15, $40, $55, $50, $15, $40
.byte $55, $50, $50, $50, $50, $50, $50, $14
.byte $50, $14, $50, $50, $55, $54, $82, $82
.byte $2a, $80, $0, $0, $0, $0, $0, $0
.byte $2, $80, $2a, $a0, $a, $0, $2a, $80
.byte $2a, $80, $2, $a0, $aa, $a0, $a, $80
.byte $aa, $a0, $2a, $80, $2a, $80, $a, $0
.byte $aa, $a0, $a, $a0, $aa, $80, $aa, $a8
.byte $aa, $a8, $a, $a0, $a0, $a0, $2a, $80
.byte $2, $a8, $a8, $28, $aa, $0, $a0, $28
.byte $a0, $28, $a, $80, $aa, $a0, $2a, $80
.byte $aa, $a0, $2a, $80, $aa, $a0, $a0, $a0
.byte $a0, $a0, $a0, $28, $a0, $28, $a0, $a0
.byte $aa, $a8, $c3, $c3, $3f, $c0, $0, $0
.byte $0, $0, $0, $0, $3, $c0, $3f, $f0
.byte $f, $0, $3f, $c0, $3f, $c0, $3, $f0
.byte $ff, $f0, $f, $c0, $ff, $f0, $3f, $c0
.byte $3f, $c0, $f, $0, $ff, $f0, $f, $f0
.byte $ff, $c0, $ff, $fc, $ff, $fc, $f, $f0
.byte $f0, $f0, $3f, $c0, $3, $fc, $fc, $3c
.byte $ff, $0, $f0, $3c, $f0, $3c, $f, $c0
.byte $ff, $f0, $3f, $c0, $ff, $f0, $3f, $c0
.byte $ff, $f0, $f0, $f0, $f0, $f0, $f0, $3c
.byte $f0, $3c, $f0, $f0, $ff, $fc, $0, $0

137
libsrc/atari7800/cputc.s Normal file
View File

@@ -0,0 +1,137 @@
;
; Mark Keates, Christian Groessler, Piotr Fusik, Karri Kaksonen
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;
.export _cputc
.import gotox, gotoy, pusha0
.import pushax
.import _screen
.import txtcolor
.include "atari7800.inc"
.include "extzp.inc"
.code
;---------------------------------------------------------------------------
; 8x16 routine
umula0:
ldy #8 ; Number of bits
lda #0
lsr ptr7800 ; Get first bit into carry
@L0: bcc @L1
clc
adc ptrtmp
tax
lda ptrtmp+1 ; hi byte of left op
clc
adc ptr7800+1
sta ptr7800+1
txa
@L1: ror ptr7800+1
ror a
ror ptr7800
dey
bne @L0
tax
lda ptr7800 ; Load the result
rts
;-----------------------------------------------------------------------------
; Put a character on screen
;
; The code will handle newlines that wrap to start of screen
;
.proc _cputc
cmp #$0A ; LF
bne @L4
@L1: lda CURS_Y ; newline
cmp #(screenrows-1)
bne @L2
lda #0
beq @L3
@L2: clc
adc #1
@L3: jsr gotoy
lda #0
jmp gotox
@L4:
cmp #$20 ; ' '
bne @L5
lda #$00
jmp @L10
@L5:
cmp #$3F ; '?'
bne @L6
lda #$02
jmp @L9
@L6:
cmp #$7C ; '|'
bne @L7
lda #$06
jmp @L9
@L7:
cmp #$41 ; >= 'A'
bcc @L8
and #$5F ; make upper case
sec
sbc #($41 - 17)
jmp @L9
@L8:
sec ; >= '*'
sbc #($2A - 1)
@L9:
clc
adc txtcolor
@L10:
asl
pha
lda #0
sta ptr7800+1
sta ptrtmp+1
lda CURS_Y ; Find position on screen buffer
sta ptr7800
lda #charsperline
sta ptrtmp
jsr umula0
clc
adc CURS_X
bcc @L11
inx
@L11: clc
adc #<(_screen)
sta ptr7800
bcc @L12
inx
@L12: txa
clc
adc #>(_screen)
sta ptr7800+1
pla ; Print character on screen
ldy #0
sta (ptr7800),y
lda CURS_X ; Increment cursor
cmp #(charsperline-1)
beq @L1
clc
adc #1
jmp gotox
.endproc
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

71
libsrc/atari7800/crt0.s Normal file
View File

@@ -0,0 +1,71 @@
.export _zonecounter
.export __STARTUP__ : absolute = 1
.export _exit
.import __ROM_START__
.import __RAM3_START__, __RAM3_SIZE__
.import initlib, donelib
.import zerobss, copydata
.import IRQStub
.import push0, _main
.include "atari7800.inc"
.include "zeropage.inc"
INPTCTRL = $01
.segment "STARTUP"
start:
; Startup sequence recommended by Atari.
; See the 7800 standards document.
sei ; Initialize 6502
cld
lda #$07 ; Lock machine in 7800 mode
sta INPTCTRL
lda #$7f ; DMA off
sta CTRL
ldx #0 ; OFFSET must always be 0
stx OFFSET
stx INPTCTRL ; Make sure joysticks don't freeze
dex ; Stack pointer = $ff
txs
; Set up parameter stack
lda #<(__RAM3_START__ + __RAM3_SIZE__)
sta sp
lda #>(__RAM3_START__ + __RAM3_SIZE__)
sta sp+1
jsr copydata
jsr zerobss
jsr initlib
; Call main program (pass empty command line)
jsr push0 ; argc
jsr push0 ; argv
ldy #4 ; Argument size
jsr _main
_exit:
jsr donelib
jmp start
NMIHandler:
inc _zonecounter
jmp IRQStub
IRQHandler:
rti
.segment "DATA"
_zonecounter:
.byte 0
.segment "ENCRYPTION"
.res 126, $ff ; Reserved for encryption
Lfff8: .byte $ff ; Region verification (always $ff)
Lfff9: .byte $f7 ; Use last 4096 bytes only for encryption
;;;Lfff9: .byte <(((__ROM_START__/4096)<<4) | 7)
.segment "VECTORS"
.word NMIHandler
.word start
.word IRQHandler

5
libsrc/atari7800/ctype.s Normal file
View File

@@ -0,0 +1,5 @@
; Character specification table.
;
; uses the "common" definition
.include "ctype_common.inc"

46
libsrc/atari7800/exehdr.s Normal file
View File

@@ -0,0 +1,46 @@
;
; Karri Kaksonen, 2022
;
; This header contains data for emulators
;
.export __EXEHDR__: absolute = 1
.import __CARTSIZE__
; ------------------------------------------------------------------------
; EXE header
.segment "EXEHDR"
.byte 3 ; version
.byte 'A','T','A','R','I','7','8','0','0',' ',' ',' ',' ',' ',' ',' '
.byte 'G','a','m','e',' ','n','a','m','e',0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,>__CARTSIZE__,0 ; Set the cart size in the cfg file
; bit 0 - pokey at 4000
; bit 1 - supergame bank switched
; bit 2 - supergame ram at $4000
; bit 3 - rom at $4000
; bit 4 - bank 6 at $4000
; bit 5 - supergame banked ram
; bit 6 - pokey at $450
; bit 7 - mirror ram at $4000
; bit 8 - activision banking
; bit 9 - absolute banking
; bit 10 - pokey at $440
; bit 11 - ym2151 at $461/462
; bit 12 - souper
; bit 13-15 - Special
; 0 = Normal cart
.byte 0,0 ; 0 = Normal cart
.byte 1 ; 1 = Joystick, 2 = lightgun
.byte 0 ; No joystick 2
.byte 0 ; bit0 = 0:NTSC,1:PAL bit1 = 0:component,1:composite
.byte 0 ; Save data peripheral - 1 byte (version 2)
; 0 = None / unknown (default)
; 1 = High Score Cart (HSC)
; 2 = SaveKey
.byte 0 ; 63 Expansion module
; 0 = No expansion module (default on all currently released games)
; 1 = Expansion module required
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 'A','C','T','U','A','L',' ','C','A','R','T',' ','D','A','T','A',' ','S','T','A','R','T','S',' ','H','E','R','E'

View File

@@ -0,0 +1,28 @@
;
; Groepaz/Hitmen, 19.10.2015
;
; import/overload stubs for the monochrome conio implementation
;
; mono_conio.s
.import _mono_screen
.export _screen := _mono_screen
; mono_clrscr.s
.import _mono_clrscr
.export _clrscr := _mono_clrscr
; mono_cputc.s
.import _mono_cputc
.export _cputc := _mono_cputc
; mono_font.s
.import _mono_font
.export _font := _mono_font
; mono_setcursor.s
.import mono_gotoxy
.export gotoxy := mono_gotoxy
.import _mono_gotoxy
.export _gotoxy := _mono_gotoxy

View File

@@ -0,0 +1,15 @@
;
; extzp.inc for the Atari 7800
;
; Karri Kaksonen, 2022-04-05
;
; Assembler include file that imports the runtime zero page locations used
; by the atari7800 runtime, ready for usage in asm code.
;
.global ptr7800: zp
.global ptrtmp: zp
.global cursorzone: zp
.global CURS_X: zp
.global CURS_Y: zp

15
libsrc/atari7800/extzp.s Normal file
View File

@@ -0,0 +1,15 @@
;
; Karri Kaksonen, 2022-04-05
;
; zeropage locations for exclusive use by the library
;
.include "extzp.inc"
.segment "EXTZP" : zeropage
ptr7800: .res 2
ptrtmp: .res 2
cursorzone: .res 2
CURS_X: .res 1
CURS_Y: .res 1

65
libsrc/atari7800/get_tv.s Normal file
View File

@@ -0,0 +1,65 @@
;
; Karri Kaksonen, 2022-03-25
;
; unsigned char get_tv (void)
;
.include "atari7800.inc"
.include "get_tv.inc"
.export _get_tv
.export _paldetected
.segment "DATA"
_paldetected:
.byte $FF
; ---------------------------------------------------------------
; unsigned char get_tv (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _get_tv: near
.segment "CODE"
ldx #$00
lda #$FF
cmp _paldetected
bne L8
L1: lda MSTAT
and #$80
bne L1
L2: lda MSTAT
and #$80
beq L2
L3: lda MSTAT
and #$80
bne L3
lda #$00
sta M0001
jmp L5
L4: sta MWSYNC
sta MWSYNC
dec M0001
L5: lda MSTAT
and #$80
beq L4
lda M0001
cmp #$78
bcc L6
lda #TV::NTSC
jmp L7
L6: lda #TV::PAL
L7: sta _paldetected
ldx #$00
L8: lda _paldetected
rts
.segment "BSS"
M0001:
.res 1,$00
.endproc

36
libsrc/atari7800/irq.s Normal file
View File

@@ -0,0 +1,36 @@
;
; IRQ handling (Atari 7800 version)
;
.export initirq, doneirq, IRQStub
.import __INTERRUPTOR_COUNT__, callirq
.include "atari7800.inc"
.code
; ------------------------------------------------------------------------
initirq:
doneirq:
rts
; ------------------------------------------------------------------------
IRQStub:
cld ; Just to be sure
pha
lda #<(__INTERRUPTOR_COUNT__ * 2)
beq @L1
txa
pha
tya
pha
jsr callirq ; Call the functions
pla
tay
pla
tax
@L1: pla
rti

View File

@@ -0,0 +1,161 @@
;
; Standard joystick driver for the Atari 7800.
; This version tries to use 7800 and 2600 joysticks.
; But assumes that both joysticks are of same type.
;
; Modified by Karri Kaksonen, 2022-03-31
; Ullrich von Bassewitz, 2002-12-20
; Using code from Steve Schmidtke
;
.include "zeropage.inc"
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "atari7800.inc"
.macpack generic
.macpack module
; ------------------------------------------------------------------------
; Header. Includes jump table
module_header _atari7800_stdjoy_joy
; Driver signature
.byte $6A, $6F, $79 ; "joy"
.byte JOY_API_VERSION ; Driver API version number
; Library reference
.addr $0000
; Jump table.
.addr INSTALL
.addr UNINSTALL
.addr COUNT
.addr READ
; ------------------------------------------------------------------------
; Constants
JOY_COUNT = 2 ; Number of joysticks we support
.code
; ------------------------------------------------------------------------
; INSTALL routine. Is called after the driver is loaded into memory. If
; possible, check if the hardware is present and determine the amount of
; memory available.
; Must return an JOY_ERR_xx code in a/x.
;
INSTALL:
; Assume 7800 2-button controller, can change
; to 2600 1-button later
lda #$14
sta CTLSWB ; enable 2-button 7800 controller 1: set pin 6 to output
ldy #$00
sty SWCHB ; enable 2-button 7800 controller 2: pull pin 6 (INPT4) high
reset:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
; Can do cleanup or whatever. Must not return anything.
;
UNINSTALL:
rts
; ------------------------------------------------------------------------
; COUNT: Return the total number of available joysticks in a/x.
;
COUNT:
lda #<JOY_COUNT
ldx #>JOY_COUNT
rts
; ------------------------------------------------------------------------
; READ: Read a particular joystick passed in A for 2 fire buttons.
readbuttons:
; Y has joystick of interest 0/1
; return value:
; $00: no button,
; $01: left/B button,
; $02: right/A button,
; $03: both buttons
; preserves X
tya
beq L5
; Joystick 1 processing
; 7800 joystick 1 buttons
ldy #0 ; ........
bit INPT2 ; Check for right button
bpl L1
ldy #2 ; ......2.
L1: bit INPT3 ;Check for left button
bpl L2
iny ; ......21
L2: tya
bne L4 ; 7800 mode joystick worked
; 2600 Joystick 1
bit INPT5
bmi L4
L3: iny ; .......1
lda #0 ; Fallback to 2600 joystick mode
sta CTLSWB
L4: tya ; ......21
rts
L5: ; Joystick 0 processing
; 7800 joystick 0 buttons
ldy #0 ; ........
bit INPT0 ; Check for right button
bpl L6
ldy #2 ; ......2.
L6: bit INPT1 ;Check for left button
bpl L7
iny ; ......21
L7: tya
bne L4 ; 7800 mode joystick worked
; 2600 Joystick 0
bit INPT4
bmi L4
bpl L3
READ:
tay ; Store joystick 0/1 in Y
beq L8
lda SWCHA ; Read directions of joystick 1
rol ; ...RLDU.
rol ; ..RLDU..
rol ; .RLDU... - joystick 1
jmp L9
L8: lda SWCHA ; Read directions of joystick 0
ror ; .RLDU... - joystick 0
L9: tax
jsr readbuttons ; A = ......21, X = .RLDU...
ror ; A = .......2 1
tay ; Y = .......2
txa ; A = .RLDU...
ror ; A = 1.RLDU..
tax ; X = 1.RLDU..
tya ; A = .......2
ror ; A = ........ 2
txa ; A = 1.RLDU..
rol ; A = .RLDU..2 1
rol ; A = RLDU..21
eor #$F0 ; The direction buttons were inversed
and #$F3
rts

View File

@@ -0,0 +1,14 @@
;
; Address of the static standard joystick driver
;
; Oliver Schmidt, 2012-11-01
;
; const void joy_static_stddrv[];
;
.export _joy_static_stddrv
.import _atari7800_stdjoy_joy
.rodata
_joy_static_stddrv := _atari7800_stdjoy_joy

View File

@@ -0,0 +1,8 @@
;
; Oliver Schmidt, 2013-05-31
;
.export joy_libref
.import _exit
joy_libref := _exit

View File

@@ -0,0 +1,27 @@
.include "atari7800.inc"
.export _mono_clrscr
.import _mono_screen
.import pushax, __bzero
.include "extzp.inc"
.code
.proc _mono_clrscr
lda #<_mono_screen
ldx #>_mono_screen
jsr pushax
ldx #>(mono_charsperline * screenrows)
lda #<(mono_charsperline * screenrows)
jmp __bzero
.endproc
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import mono_initconio
conio_init = mono_initconio

View File

@@ -0,0 +1,231 @@
;
; 2022-04-02, Karri Kaksonen
;
; The Atari 7800 has only 4k of RAM. So for a generic conio implementation
; the best alternative is to use indirect tile mapping with a character
; frame buffer
;
.constructor mono_initconio
.include "atari7800.inc"
.include "extzp.inc"
.import _mono_font
.import _get_tv
.export _mono_screen
.export _mono_zones
.export _mono_dll
.bss
_mono_screen:
.res mono_charsperline * screenrows
;----------------------------------------------------------------------------
; Macros used to generate lists
.macro DLLentry offset, addr
.byte offset
.byte >addr
.byte <addr
.endmacro
.macro NullHeader offset, zero
.byte offset
.byte zero
.endmacro
.macro Header addr, palwidth, hpos
.byte <addr
.byte palwidth
.byte >addr
.byte hpos
.endmacro
.macro XHeader addr, flags, palwidth, hpos
.byte <addr
.byte flags
.byte >addr
.byte palwidth
.byte hpos
.endmacro
.macro TextZone row
; Text
.byte <(_mono_screen + row * mono_charsperline)
.byte $60
.byte >(_mono_screen + row * mono_charsperline)
.byte 12
.byte 0
.byte <(_mono_screen + row * mono_charsperline + 20)
.byte $60
.byte >(_mono_screen + row * mono_charsperline + 20)
.byte 12
.byte 80
; Cursor
.byte 95
.byte 0
.byte >_mono_font
.byte 0
.endmacro
;-----------------------------------------------------------------------------
; The Atari 7800 has only 4k of RAM. So for a generic conio implementation
; the best alternative is to use indirect tile mapping with a character
; frame buffer
.data
_mono_zones:
zone0: TextZone 0
nh: NullHeader 0, 0
zone1: TextZone 1
NullHeader 0, 0
zone2: TextZone 2
NullHeader 0, 0
zone3: TextZone 3
NullHeader 0, 0
zone4: TextZone 4
NullHeader 0, 0
zone5: TextZone 5
NullHeader 0, 0
zone6: TextZone 6
NullHeader 0, 0
zone7: TextZone 7
NullHeader 0, 0
zone8: TextZone 8
NullHeader 0, 0
zone9: TextZone 9
NullHeader 0, 0
zone10: TextZone 10
NullHeader 0, 0
zone11: TextZone 11
NullHeader 0, 0
zone12: TextZone 12
NullHeader 0, 0
zone13: TextZone 13
NullHeader 0, 0
zone14: TextZone 14
NullHeader 0, 0
zone15: TextZone 15
NullHeader 0, 0
zone16: TextZone 16
NullHeader 0, 0
zone17: TextZone 17
NullHeader 0, 0
zone18: TextZone 18
NullHeader 0, 0
zone19: TextZone 19
NullHeader 0, 0
zone20: TextZone 20
NullHeader 0, 0
zone21: TextZone 21
NullHeader 0, 0
zone22: TextZone 22
NullHeader 0, 0
zone23: TextZone 23
NullHeader 0, 0
zone24: TextZone 24
NullHeader 0, 0
zone25: TextZone 25
NullHeader 0, 0
zone26: TextZone 26
NullHeader 0, 0
zone27: TextZone 27
NullHeader 0, 0
_mono_dll:
PALscanlines: ; 25 lines
DLLentry 15, nh
DLLentry 8, nh
Topscanlines: ; 9 lines
DLLentry 8, nh
Displaylines:
DLLentry $80+7, zone0 ; NMI interrupt from end of prev zone
DLLentry 7, zone1
DLLentry 7, zone2
DLLentry 7, zone3
DLLentry 7, zone4
DLLentry 7, zone5
DLLentry 7, zone6
DLLentry 7, zone7
DLLentry 7, zone8
DLLentry 7, zone9
DLLentry 7, zone10
DLLentry 7, zone11
DLLentry 7, zone12
DLLentry 7, zone13
DLLentry 7, zone14
DLLentry 7, zone15
DLLentry 7, zone16
DLLentry 7, zone17
DLLentry 7, zone18
DLLentry 7, zone19
DLLentry 7, zone20
DLLentry 7, zone21
DLLentry 7, zone22
DLLentry 7, zone23
DLLentry 7, zone24
DLLentry 7, zone25
DLLentry 7, zone26
DLLentry 7, zone27
Bottomscanlines:
DLLentry $80+15, nh ; NMI interrupt at end of display
DLLentry 9, nh
DLLentry 15, nh
DLLentry 8, nh
;-----------------------------------------------------------------------------
; Set up the screen to 320a mode
;
.segment "ONCE"
CTRL_MODE160 .set 0
CTRL_MODEAC .set 3
CTRL_KANGOFF .set 0
CTRL_BCBLACK .set 0
CTRL_CHAR1B .set 0
CTRL_CHAR2B .set $10
CTRL_DMAON .set $40
CTRL_CKOFF .set 0
;-----------------------------------------------------------------------------
; Initialize the conio display lists and zones
;
.proc mono_initconio
jsr _get_tv
bne pal
lda #<Topscanlines
sta DPPL
lda #>Topscanlines
sta DPPH
jmp vblankon
pal: lda #<PALscanlines
sta DPPL
lda #>PALscanlines
sta DPPH
vblankon:
lda MSTAT
bmi vblankon
vblankoff:
lda MSTAT
bpl vblankoff
lda #>_mono_font
sta CHBASE
lda #(CTRL_MODEAC | CTRL_KANGOFF | CTRL_BCBLACK | CTRL_CHAR1B | CTRL_DMAON | CTRL_CKOFF)
sta CTRL
lda #$00 ; Black background
sta BKGRND
sta CURS_X
sta CURS_Y
lda #$33 ; Red
sta P0C1
lda #$c8 ; Green
sta P0C2
lda #$0f ; White
sta P0C3
rts
.endproc

View File

@@ -0,0 +1,102 @@
;
; Mark Keates, Christian Groessler, Piotr Fusik, Karri Kaksonen
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;
.export _mono_cputc
.import mono_gotox, mono_gotoy, pusha0
.import pushax
.import _mono_screen
.include "atari7800.inc"
.include "extzp.inc"
.code
;---------------------------------------------------------------------------
; 8x16 routine
umula0:
ldy #8 ; Number of bits
lda #0
lsr ptr7800 ; Get first bit into carry
@L0: bcc @L1
clc
adc ptrtmp
tax
lda ptrtmp+1 ; hi byte of left op
clc
adc ptr7800+1
sta ptr7800+1
txa
@L1: ror ptr7800+1
ror a
ror ptr7800
dey
bne @L0
tax
lda ptr7800 ; Load the result
rts
;-----------------------------------------------------------------------------
; Put a character on screen
;
; The code will handle newlines that wrap to start of screen
;
.proc _mono_cputc
cmp #$0A ; LF
bne @L4
@L1: lda #0 ; newline
jsr mono_gotox
lda CURS_Y
cmp #(screenrows-1)
bne @L2
lda #0
beq @L3
@L2: clc
adc #1
@L3: jmp mono_gotoy
@L4:
pha
lda #0
sta ptr7800+1
sta ptrtmp+1
lda CURS_Y ; Find position on screen buffer
sta ptr7800
lda #mono_charsperline
sta ptrtmp
jsr umula0
clc
adc CURS_X
bcc @L11
inx
@L11: clc
adc #<(_mono_screen)
sta ptr7800
bcc @L12
inx
@L12: txa
clc
adc #>(_mono_screen)
sta ptr7800+1
pla ; Print character on screen
ldy #0
sta (ptr7800),y
lda CURS_X ; Increment cursor
cmp #(mono_charsperline-1)
beq @L1
clc
adc #1
jmp mono_gotox
.endproc

2065
libsrc/atari7800/mono_font.s Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,214 @@
;
; 2022-04-03, Karri Kaksonen
;
; setcursor (unsigned char on);
;
; The Atari 7800 does not have a hw cursor.
; This module emulates a cursor to be used with the conio
; implementation.
;
; The actual cursor display is included in the conio dll
; but every scanline has the element silenced by default
; at the end of every zone.
;
; The way the cursor works is to silence it before the cursor
; position changes and enable it afterwards.
;
; In order to get some performance we have a pointer to the
; cursor header structure. This structure is always at the
; end of the zone. So the pointer changes when CURS_Y changes.
;
; There is so many dependencies that it makes sense to
; deal with all CURS_X, CURS_Y stuff in this file and
; definitely not allow direct access to the variables.
;
.export mono_gotoxy, _mono_gotoxy, mono_gotox, mono_gotoy
.constructor mono_init_cursor
.interruptor mono_blink_cursor
.importzp sp
.import _zonecounter
.import _mono_zones
.import cursor
.import pusha, incsp1, pusha0, pushax, popa
.include "atari7800.inc"
.include "extzp.inc"
.macpack generic
.data
;-----------------------------------------------------------------------------
; The variables used by cursor functions
;
blink_time:
.byte 200
.code
;---------------------------------------------------------------------------
; 8x16 routine
umula0:
ldy #8 ; Number of bits
lda #0
lsr ptr7800 ; Get first bit into carry
@L0: bcc @L1
clc
adc ptrtmp
tax
lda ptrtmp+1 ; hi byte of left op
adc ptr7800+1
sta ptr7800+1
txa
@L1: ror ptr7800+1
ror a
ror ptr7800
dey
bne @L0
tax
lda ptr7800 ; Load the result
rts
;-----------------------------------------------------------------------------
; Calculate cursorzone address
; You also need to set the cursorzone to point to the correct cursor Header
; at the end of line CURS_Y.
; Offset to cursor zone 5. To next line offset 11
; cursorzone points to _mono_zones + CURS_Y * 16 + 10
; A = CURS_Y
.proc calccursorzone
sta ptr7800
lda #16
sta ptrtmp
lda #0
sta ptr7800+1
sta ptrtmp+1
jsr umula0
clc
adc #10
bcc @L1
inx
@L1: clc
adc #<_mono_zones
sta cursorzone ; calculate new cursorzone
txa
adc #>_mono_zones
sta cursorzone+1
rts
.endproc
;-----------------------------------------------------------------------------
; Set cursor to Y position.
; You also need to set the cursorzone to point to the correct cursor Header
; at the end of line CURS_Y.
; Offset to cursor zone 5. To next line offset 11
; cursorzone points to _mono_zones + CURS_Y * 11 + 5
;
; cursorzone[1] = 0 when not CURS_Y, 31 if CURS_Y
;
; Disable cursor
; cursorzone[1] = 0
;
; Enable cursor
; if showcursor cursorzone[1] = 31
;
.proc mono_gotoy
pha
lda CURS_Y
jsr calccursorzone
ldy #1
lda #0
sta (cursorzone),y ; disable cursor
pla
sta CURS_Y
jsr calccursorzone
lda cursor
beq @L1
lda #31 ; enable cursor
@L1: ldy #1
sta (cursorzone),y
rts
.endproc
;-----------------------------------------------------------------------------
; Set cursor to X position.
; You also need to set the hpos offset to the correct value on this line
; cursorzone[3] = 4 * CURS_X?
;
.proc mono_gotox
sta CURS_X
ldy #3
clc
rol
rol
sta (cursorzone),y
rts
.endproc
;-----------------------------------------------------------------------------
; Set cursor to desired position (X,Y)
;
.proc _mono_gotoxy
jsr mono_gotoy
jsr popa
jmp mono_gotox
.endproc
.proc mono_gotoxy
jsr popa
jmp _mono_gotoxy
.endproc
;-----------------------------------------------------------------------------
; Initialize cursorzone at startup
; Offset to cursor zone 5.
;
.proc mono_blink_cursor
lda _zonecounter
and #01
beq @L3
inc blink_time
bne @L3
lda #200
sta blink_time
ldy #0
lda (cursorzone),y
cmp #32
bne @L1
lda #95
bne @L2
@L1: lda #32
@L2: sta (cursorzone),y
@L3: rts
.endproc
;-----------------------------------------------------------------------------
; Initialize cursorzone at startup
; Offset to cursor zone 5.
;
.segment "ONCE"
mono_init_cursor:
lda #0
jsr calccursorzone
lda #0
sta blink_time
rts
;-----------------------------------------------------------------------------
; force the init constructor to be imported
.import mono_initconio
conio_init = mono_initconio

View File

@@ -0,0 +1,214 @@
;
; 2022-04-03, Karri Kaksonen
;
; setcursor (unsigned char on);
;
; The Atari 7800 does not have a hw cursor.
; This module emulates a cursor to be used with the conio
; implementation.
;
; The actual cursor display is included in the conio dll
; but every scanline has the element silenced by default
; at the end of every zone.
;
; The way the cursor works is to silence it before the cursor
; position changes and enable it afterwards.
;
; In order to get some performance we have a pointer to the
; cursor header structure. This structure is always at the
; end of the zone. So the pointer changes when CURS_Y changes.
;
; There is so many dependencies that it makes sense to
; deal with all CURS_X, CURS_Y stuff in this file and
; definitely not allow direct access to the variables.
;
.export gotoxy, _gotoxy, gotox, gotoy
.constructor init_cursor
.interruptor blink_cursor
.importzp sp
.import _zonecounter
.import _zones
.import cursor
.import pusha, incsp1, pusha0, pushax, popa
.include "atari7800.inc"
.include "extzp.inc"
.macpack generic
.data
;-----------------------------------------------------------------------------
; The variables used by cursor functions
;
blink_time:
.byte 200
.code
;---------------------------------------------------------------------------
; 8x16 routine
umula0:
ldy #8 ; Number of bits
lda #0
lsr ptr7800 ; Get first bit into carry
@L0: bcc @L1
clc
adc ptrtmp
tax
lda ptrtmp+1 ; hi byte of left op
clc
adc ptr7800+1
sta ptr7800+1
txa
@L1: ror ptr7800+1
ror a
ror ptr7800
dey
bne @L0
tax
lda ptr7800 ; Load the result
rts
;-----------------------------------------------------------------------------
; Calculate cursorzone address
; You also need to set the cursorzone to point to the correct cursor Header
; at the end of line CURS_Y.
; Offset to cursor zone 5. To next line offset 11
; cursorzone points to _zones + CURS_Y * 11 + 5
; A = CURS_Y
.proc calccursorzone
sta ptr7800
lda #11
sta ptrtmp
lda #0
sta ptr7800+1
sta ptrtmp+1
jsr umula0
clc
adc #5
bcc @L1
inx
@L1: clc
adc #<_zones
sta cursorzone ; calculate new cursorzone
txa
adc #>_zones
sta cursorzone+1
rts
.endproc
;-----------------------------------------------------------------------------
; Set cursor to Y position.
; You also need to set the cursorzone to point to the correct cursor Header
; at the end of line CURS_Y.
; Offset to cursor zone 5. To next line offset 11
; cursorzone points to _zones + CURS_Y * 11 + 5
;
; cursorzone[1] = 0 when not CURS_Y, 30 if CURS_Y
;
; Disable cursor
; cursorzone[1] = 0
;
; Enable cursor
; if showcursor cursorzone[1] = 30
;
.proc gotoy
pha
lda CURS_Y
jsr calccursorzone
ldy #1
lda #0
sta (cursorzone),y ; disable cursor
pla
sta CURS_Y
jsr calccursorzone
lda cursor
beq @L1
lda #30 ; enable cursor
@L1: ldy #1
sta (cursorzone),y
rts
.endproc
;-----------------------------------------------------------------------------
; Set cursor to X position.
; You also need to set the hpos offset to the correct value on this line
; cursorzone[3] = 8 * CURS_X
;
.proc gotox
sta CURS_X
ldy #3
clc
rol
rol
rol
sta (cursorzone),y
rts
.endproc
;-----------------------------------------------------------------------------
; Set cursor to desired position (X,Y)
;
.proc _gotoxy
jsr gotoy
jsr popa
jsr gotox
rts
.endproc
.proc gotoxy
jsr popa
jmp _gotoxy
.endproc
;-----------------------------------------------------------------------------
; Initialize cursorzone at startup
; Offset to cursor zone 5.
;
.proc blink_cursor
lda _zonecounter
and #01
beq @L3
inc blink_time
bne @L3
lda #200
sta blink_time
ldy #0
lda (cursorzone),y
bne @L1
lda #254
bne @L2
@L1: lda #0
@L2: sta (cursorzone),y
@L3: rts
.endproc
;-----------------------------------------------------------------------------
; Initialize cursorzone at startup
; Offset to cursor zone 5.
;
.segment "ONCE"
init_cursor:
lda #0
jsr calccursorzone
lda #0
sta blink_time
rts
;-----------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

View File

@@ -0,0 +1,53 @@
;
; Karri Kaksonen, 2022-04-16
;
;
.export _textcolor
.export txtcolor
.include "atari7800.inc"
.data
;-----------------------------------------------------------------------------
; Holder of the text colour offset
; 0 = red, 42 = green, 84 = white
;
txtcolor:
.byte 0
.code
;-----------------------------------------------------------------------------
; Change the text colour
;
; Logical colour names are
; 0 = red
; 1 = green
; 2 = white
;
; The routine will also return the previous textcolor
;
.proc _textcolor
beq @L2
sec
sbc #1
beq @L1
lda #84
jmp @L2
@L1: lda #42
@L2: ldy txtcolor
sta txtcolor ; Store new textcolor
ldx #0
tya
bne @L3
rts ; Old colour was 0
@L3: sec
sbc #42
bne @L4
lda #1
rts ; Old colour was 1
@L4: lda #2
rts ; Old colour was 2
.endproc

19
libsrc/atari7800/wherex.s Normal file
View File

@@ -0,0 +1,19 @@
;
; 2022-04-16, Karri Kaksonen
;
; unsigned char wherex()
;
.export _wherex
.include "extzp.inc"
;-----------------------------------------------------------------------------
; Get cursor X position
;
.proc _wherex
ldx #0
lda CURS_X
rts
.endproc

19
libsrc/atari7800/wherey.s Normal file
View File

@@ -0,0 +1,19 @@
;
; 2022-04-16, Karri Kaksonen
;
; unsigned char wherey()
;
.export _wherey
.include "extzp.inc"
;-----------------------------------------------------------------------------
; Get cursor Y position
;
.proc _wherey
ldx #0
lda CURS_Y
rts
.endproc

View File

@@ -6,7 +6,7 @@
;
.export _cclearxy, _cclear
.import setscrptr
.import setscrptr
.import rvs
.import popax
.importzp ptr2
@@ -25,7 +25,7 @@ _cclear:
tax ; Is the length zero?
beq @L9 ; Jump if done
jsr setscrptr ; Set ptr2 to screen, won't use X
lda #' '
lda #' '
ora rvs
@L1: sta (ptr2),y ; Write one char
iny ; Next char

View File

@@ -119,7 +119,7 @@ __ctypeidx:
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 186/ba ___________, 187/bb ___________
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 188/bc ___________, 189/bd ___________
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 190/be ___________, 191/bf ___________
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 192/c0 ___________, 193/c1 ___________
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 194/c2 ___________, 195/c3 ___________
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 196/c4 ___________, 197/c5 ___________

View File

@@ -72,7 +72,7 @@ reu_params: .word $0000 ; Host address, lo, hi
.byte $00 ; Expansion bank no.
.word $0000 ; # bytes to move, lo, hi
.byte $00 ; Interrupt mask reg.
.byte $00 ; Adress control reg.
.byte $00 ; Address control reg.
.code

View File

@@ -73,7 +73,7 @@ INSTALL:
lda #$ff
sta curpage
sta curpage+1
; do test for VDC presence here???
ldx #VDC_CSET ; determine size of RAM...
jsr vdcgetreg
@@ -97,29 +97,29 @@ INSTALL:
jsr vdcputbyte ; restore original value of test byte
ldx #0 ; prepare x with hi of default pagecount
lda ptr1 ; do bytes match?
cmp ptr1+1
bne @have64k
lda ptr2
cmp ptr2+1
bne @have64k
lda #64 ; assumes x = 0, here -> p.c = 64
bne @setpagecnt
@have64k:
@have64k:
txa ; assumes x = 0, here
inx ; so that a/x becomes 0/1 -> p.c. = 256
@setpagecnt:
@setpagecnt:
sta pagecount
stx pagecount+1
txa
bne @keep64kBit
bne @keep64kBit
ldx #VDC_CSET ; restore 16/64k flag
lda vdc_cset_save
jsr vdcputreg
lda vdc_cset_save
jsr vdcputreg
@keep64kBit:
lda #<EM_ERR_OK
ldx #>EM_ERR_OK

View File

@@ -73,7 +73,7 @@ reu_params: .word $0000 ; Host address, lo, hi
.byte $00 ; Expansion bank no.
.word $0000 ; # bytes to move, lo, hi
.byte $00 ; Interrupt mask reg.
.byte $00 ; Adress control reg.
.byte $00 ; Address control reg.
.code

View File

@@ -12,7 +12,7 @@
;--------------------------------------------------------------------------
; Data. We define a fixed utsname struct here and just copy it.
.rodata
utsdata:

View File

@@ -12,9 +12,9 @@
/* saves a memory area from start to end-1 to a file.
*/
unsigned char __fastcall__ cbm_save (const char* name,
unsigned char __fastcall__ cbm_save (const char* name,
unsigned char device,
const void* data,
const void* data,
unsigned int size)
{
cbm_k_setlfs(0, device, 0);

View File

@@ -13,7 +13,7 @@
.include "ctypetable.inc"
.export __ctypeidx
; The tables are readonly, put them into the rodata segment
.rodata

View File

@@ -130,7 +130,7 @@ dowrite:
beq notrunc
jsr scratch
; Complete the the file name. Check for append mode here.
; Complete the file name. Check for append mode here.
notrunc:
lda tmp3 ; Get the mode again
@@ -168,7 +168,7 @@ nofile: ; ... else use SA=0 (read)
jsr OPEN
bcs oserror
; Open the the drive command channel and read it
; Open the drive command channel and read it
ldx fnunit
jsr opencmdchannel

View File

@@ -38,7 +38,7 @@ DIR* __fastcall__ opendir (register const char* name)
d.fd = open (d.name, O_RDONLY);
if (d.fd >= 0) {
/* Skip the load address */
/* Skip the load address */
if (_dirread (&d, buf, sizeof (buf))) {
/* Allocate memory for the DIR structure returned */

View File

@@ -9,7 +9,7 @@
.import RVS: zp
.include "cbm610.inc"
.proc _revers

View File

@@ -39,4 +39,4 @@ initheap:
sta __heapend+1
rts

View File

@@ -6,7 +6,7 @@
; size_t _heapmaxavail (void);
;
;
.importzp ptr1, ptr2
.export __heapmaxavail

View File

@@ -1,9 +1,9 @@
/*
** Ullrich von Bassewitz, 2012-11-26
**
** Minimum value of a long. Is used in ascii conversions, since this value
** Minimum value of a long. Is used in ascii conversions, since this value
** has no positive counterpart than can be represented in 32 bits. In C,
** since the compiler will convert to the correct character set for the
** since the compiler will convert to the correct character set for the
** target platform.
*/

View File

@@ -2,7 +2,7 @@
; Ullrich von Bassewitz, 2004-05-13
;
; __seterrno: Will set __errno to the value in A and return zero in A. Other
; registers aren't changed. The function is C callable, but
; registers aren't changed. The function is C callable, but
; currently only called from asm code.
;

View File

@@ -7,7 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <signal.h>

View File

@@ -9,7 +9,7 @@
;
; ctypemask(int c)
;
; converts a character to test via the is*-functions to the matching ctype-masks
; converts a character to test via the is*-functions to the matching ctype-masks
; If c is out of the 8-bit range, the function returns with carry set and accu cleared.
; Return value is in accu and x has to be always clear when returning
; (makes calling code shorter)!

View File

@@ -18,10 +18,10 @@
.importzp sreg, ptr1, tmp1
_div: jsr tosdivax ; Division-operator does most of the work
ldy sreg ; low byte remainder from sreg
sta sreg ; store low byte quotient to sreg
lda sreg+1 ; high byte remainder from sreg
stx sreg+1 ; store high byte quotient to sreg

View File

@@ -7,6 +7,6 @@
;
.export _doesclrscrafterexit
.import return0
.import return0
_doesclrscrafterexit = return0

View File

@@ -161,7 +161,7 @@
bne @L8
; Error in read. Set the stream error flag and bail out. errno has already
; been set by read(). On entry to label @L7, X must be zero.
; been set by read(). On entry to label @L7, X must be zero.
inx ; X = 0
lda #_FERROR

View File

@@ -274,7 +274,7 @@ _free: sta ptr2
; }
; }
;
;
;
; On entry, ptr2 must contain a pointer to the block, which must be at least
; HEAP_MIN_BLOCKSIZE bytes in size, and ptr1 contains the total size of the
; block.

View File

@@ -31,7 +31,7 @@ FILE* __fastcall__ freopen (const char* name, const char* mode, FILE* f)
** overwritten by _fopen.
*/
if (close (f->f_fd) < 0) {
/* An error occured, errno is already set */
/* An error occurred, errno is already set */
return 0;
}

View File

@@ -21,4 +21,4 @@ int __fastcall__ fsetpos (FILE* f, const fpos_t *pos)
return fseek (f, (fpos_t)*pos, SEEK_SET);
}

View File

@@ -19,7 +19,7 @@
; ------------------------------------------------------------------------
; Code
.proc _fwrite
; Save file and place it into ptr1

View File

@@ -53,7 +53,7 @@ overflow:
lda #<ERANGE
jsr __seterrno ; Returns 0 in A
tax ; Return zero
rts
rts
; Success, return buf

View File

@@ -19,7 +19,7 @@ specval:
; Common subroutine to pop the parameters and put them into core
;
dopop: sta tmp1 ; will loose high byte
dopop: sta tmp1 ; will lose high byte
ldy #0
lda (sp),y
sta ptr2

View File

@@ -18,7 +18,7 @@
; Common subroutine to pop the parameters and put them into core
;
dopop: sta tmp1 ; will loose high byte
dopop: sta tmp1 ; will lose high byte
jsr popax ; get s to ptr2
sta ptr2
stx ptr2+1
@@ -56,7 +56,7 @@ L1: lda __longminstr,y ; copy -2147483648
dey
bpl L1
jmp L10
; Check if the value is negative. If so, write a - sign and negate the
; number.
@@ -66,7 +66,7 @@ L2: txa ; get high byte
.if (.cpu .bitand CPU_ISET_65SC02)
sta (ptr2)
.else
.else
ldy #0
sta (ptr2),y ; store sign
.endif
@@ -79,7 +79,7 @@ L3: lda ptr1 ; negate val
ldx ptr1+1
jsr negeax
sta ptr1
stx ptr1+1
jmp ultoa

View File

@@ -67,7 +67,7 @@ memcpy_getparams: ; IMPORTANT! Function has to leave with Y=0!
jsr popptr1 ; save src to ptr1
; save dest to ptr2
iny ; Y=0 guaranteed by popptr1, we need '1' here...
iny ; Y=0 guaranteed by popptr1, we need '1' here...
; (direct stack access is three cycles faster
; (total cycle count with return))
lda (sp),y

View File

@@ -87,7 +87,7 @@ L3: dey
sta (ptr1),y ; set bytes in low
sta (ptr2),y ; and high section
bne L3 ; flags still up to date from dey!
leave:
leave:
jmp popax ; Pop ptr and return as result

View File

@@ -9,7 +9,7 @@
;
;
; unsigned int __fastcall__ mul20(unsigned char value);
;
;
; REMARKS: Function is defined to return with carry-flag cleared
@@ -34,7 +34,7 @@ mul5: adc tmp4 ; * 5
inx ; yes, correct...
mul10: stx tmp4 ; continue with classic shifting...
asl a ; * 10
rol tmp4

View File

@@ -9,7 +9,7 @@
;
;
; unsigned int __fastcall__ mul40(unsigned char value);
;
;
; REMARKS: Function is defined to return with carry-flag cleared
@@ -34,7 +34,7 @@ mul5: adc tmp4 ; * 5
inx ; yes, correct...
mul10: stx tmp4 ; continue with classic shifting...
asl a ; * 10
rol tmp4

View File

@@ -185,4 +185,4 @@ error: jsr __seterrno
name: .addr 0 ; Pointer to name
newsize: .byte 0 ; New environment size

View File

@@ -28,9 +28,9 @@ _raise:
sta jmpvec+1
lda sigtable+1,x
sta jmpvec+2
; Reset the signal handler to SIG_DFL (I don't like this because it may
; introduce race conditions, but it's the simplest way to satisfy the
; introduce race conditions, but it's the simplest way to satisfy the
; standard).
lda #<__sig_dfl
@@ -51,4 +51,4 @@ _raise:
invalidsig:
rts

View File

@@ -22,4 +22,4 @@ void __fastcall__ rewind (FILE* f)
clearerr(f);
}

View File

@@ -20,7 +20,7 @@ _strcspn:
sta tmp1 ; tmp1 = strlen of test chars
jsr popptr1 ; get and save s1 to ptr1
ldx #0 ; low counter byte
stx tmp2 ; high counter byte

View File

@@ -9,19 +9,19 @@
.import popax, popptr1
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
.macpack cpu
_strncat:
inx
stx tmp2
tax
inx
stx tmp1 ; save count with each byte incremented separately
jsr popptr1 ; get src
jsr popax ; get dest
sta ptr3 ; remember for function return
stx ptr3+1
stx ptr3+1
stx ptr2+1
tay ; low byte as offset in Y
.if (.cpu .bitand ::CPU_ISET_65SC02)

View File

@@ -16,8 +16,8 @@ _strrchr:
stx ptr1+1
ldx #0 ; default function result is NULL, X is high byte...
stx tmp2 ; tmp2 is low-byte
stx ptr1 ; low-byte of source string is in Y, so clear real one...
stx ptr1 ; low-byte of source string is in Y, so clear real one...
testChar:
lda (ptr1),y ; get char
beq finished ; jump if end of string

View File

@@ -68,4 +68,4 @@ error: lda #EINVAL
rts
.endproc

View File

@@ -30,7 +30,7 @@ _vsprintf:
ldy #2
jsr staxysp
; Contine by jumping to vsnprintf, which expects ap on the CPU stack and will
; Contine by jumping to vsnprintf, which expects ap on the CPU stack and will
; cleanup the C stack
jmp vsnprintf

View File

@@ -8,7 +8,7 @@
.export _cputsxy, _cputs
.import gotoxy, _cputc
.importzp ptr1, tmp1
_cputsxy:
sta ptr1 ; Save s for later
stx ptr1+1

View File

@@ -10,7 +10,7 @@
.import screensize
.importzp ptr1, ptr2
.macpack cpu
.macpack cpu
.proc _screensize
@@ -29,7 +29,7 @@
sta (ptr2),y
txa
sta (ptr1),y
.endif
.endif
rts
.endproc

View File

@@ -3,13 +3,13 @@
;*
.export screensize
.include "creativision.inc"
.proc screensize
ldx #SCREEN_COLS
ldy #SCREEN_ROWS
rts
.endproc

View File

@@ -2,7 +2,7 @@
boxchars:
; Vertical Line
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
@@ -29,7 +29,7 @@ boxchars:
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
; Top Right
.byte $00
@@ -39,7 +39,7 @@ boxchars:
.byte $18
.byte $18
.byte $18
.byte $18
.byte $18
; Bottom Left
.byte $18
@@ -49,7 +49,7 @@ boxchars:
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
; Bottom Right
.byte $18
@@ -59,4 +59,4 @@ boxchars:
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00

View File

@@ -1,5 +1,5 @@
;
; 2019-12-22, Greg King
; 2022-03-29, Greg King
;
; char cgetc (void);
; /* Return a character from the keyboard. */
@@ -13,6 +13,8 @@
.macpack generic
screen_addr := $1B000 ; VRAM address of text screen
_cgetc: jsr _kbhit
bnz L3 ; Jump if there are already chars waiting
@@ -57,8 +59,9 @@ setcursor:
stz VERA::CTRL ; Use port 0
lda CURS_Y
add #<(>screen_addr)
sta VERA::ADDR+1 ; Set row number
lda #VERA::INC1 ; Increment address by one
lda #VERA::INC1 | ^screen_addr ; Increment address by one
sta VERA::ADDR+2
lda CURS_X ; Get character column
asl a

View File

@@ -1,6 +1,6 @@
;
; 2016-02-28, Groepaz
; 2020-04-29, Greg King
; 2022-03-29, Greg King
;
; char cpeekc (void);
; /* Return the character from the current cursor position. */
@@ -9,13 +9,18 @@
.export _cpeekc
.include "cx16.inc"
.macpack generic
screen_addr := $1B000 ; VRAM address of text screen
_cpeekc:
stz VERA::CTRL ; use port 0
lda CURS_Y
add #<(>screen_addr)
sta VERA::ADDR+1 ; set row number
stz VERA::ADDR+2
lda #^screen_addr
sta VERA::ADDR+2
lda CURS_X ; get character column
asl a ; each character has two bytes
sta VERA::ADDR

View File

@@ -1,5 +1,5 @@
;
; 2020-04-30, Greg King
; 2022-03-29, Greg King
;
; unsigned char cpeekcolor (void);
; /* Return the colors from the current cursor position. */
@@ -8,8 +8,11 @@
.export _cpeekcolor
.include "cx16.inc"
.macpack generic
screen_addr := $1B000 ; VRAM address of text screen
_cpeekcolor:
php
lda CURS_FLAG ; is the cursor currently off?
@@ -22,8 +25,10 @@ _cpeekcolor:
@L1: stz VERA::CTRL ; use port 0
lda CURS_Y
add #<(>screen_addr)
sta VERA::ADDR+1 ; set row number
stz VERA::ADDR+2
lda #^screen_addr
sta VERA::ADDR+2
lda CURS_X ; get character column
sec ; color attribute is second byte
rol a

Some files were not shown because too many files have changed in this diff Show More