Changed most of the library sources to use .CAP instead of .CPU.
This commit is contained in:
@@ -9,14 +9,13 @@
|
|||||||
.importzp sreg
|
.importzp sreg
|
||||||
|
|
||||||
.include "cbm.inc"
|
.include "cbm.inc"
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
|
|
||||||
.proc _clock
|
.proc _clock
|
||||||
|
|
||||||
; Some accelerator adaptors have CMOS ICs.
|
; Some accelerator adaptors have CMOS ICs.
|
||||||
|
|
||||||
.if (.cpu & ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg + 1
|
stz sreg + 1
|
||||||
.else
|
.else
|
||||||
lda #$00 ; Byte 3 always is zero
|
lda #$00 ; Byte 3 always is zero
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
.include "errno.inc"
|
.include "errno.inc"
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
; int __fastcall__ __directerrno (unsigned char code);
|
; int __fastcall__ __directerrno (unsigned char code);
|
||||||
; /* Set errno to a specific error code, clear __oserror, and return -1. Used
|
; /* Set errno to a specific error code, clear __oserror, and return -1. Used
|
||||||
@@ -18,7 +16,7 @@
|
|||||||
___directerrno:
|
___directerrno:
|
||||||
jsr ___seterrno ; Set errno (returns with .A = 0)
|
jsr ___seterrno ; Set errno (returns with .A = 0)
|
||||||
sta ___oserror ; Clear ___oserror
|
sta ___oserror ; Clear ___oserror
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_INA)
|
||||||
dec a
|
dec a
|
||||||
.else
|
.else
|
||||||
lda #$FF ; Return -1
|
lda #$FF ; Return -1
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
.include "_heap.inc"
|
.include "_heap.inc"
|
||||||
|
|
||||||
.macpack generic
|
.macpack generic
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; Code
|
; Code
|
||||||
@@ -39,7 +38,7 @@ ___heapblocksize:
|
|||||||
ldy #usedblock::size+1
|
ldy #usedblock::size+1
|
||||||
lda (ptr2),y
|
lda (ptr2),y
|
||||||
tax
|
tax
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (ptr2)
|
lda (ptr2)
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
.include "errno.inc"
|
.include "errno.inc"
|
||||||
|
|
||||||
.macpack generic
|
.macpack generic
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
; int __fastcall__ __mappederrno (unsigned char code);
|
; int __fastcall__ __mappederrno (unsigned char code);
|
||||||
@@ -24,7 +23,7 @@ ___mappederrno:
|
|||||||
bze ok ; Branch if no
|
bze ok ; Branch if no
|
||||||
jsr ___osmaperrno ; Map OS error into errno code
|
jsr ___osmaperrno ; Map OS error into errno code
|
||||||
jsr ___seterrno ; Save in errno (returns with .A = 0)
|
jsr ___seterrno ; Save in errno (returns with .A = 0)
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_INA)
|
||||||
dec a
|
dec a
|
||||||
.else
|
.else
|
||||||
lda #$FF ; Return -1 if error
|
lda #$FF ; Return -1 if error
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
.import _strlower, _strlen
|
.import _strlower, _strlen
|
||||||
|
|
||||||
.macpack generic
|
.macpack generic
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
; We will store variables into the register bank in the zeropage. Define
|
; We will store variables into the register bank in the zeropage. Define
|
||||||
@@ -38,7 +37,7 @@ FCount = ptr2
|
|||||||
|
|
||||||
GetFormatChar:
|
GetFormatChar:
|
||||||
ldy #0
|
ldy #0
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (Format)
|
lda (Format)
|
||||||
.else
|
.else
|
||||||
lda (Format),y
|
lda (Format),y
|
||||||
@@ -115,7 +114,7 @@ GetIntArg:
|
|||||||
lda (ArgList),y
|
lda (ArgList),y
|
||||||
tax
|
tax
|
||||||
dey
|
dey
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (ArgList)
|
lda (ArgList)
|
||||||
.else
|
.else
|
||||||
lda (ArgList),y
|
lda (ArgList),y
|
||||||
@@ -274,7 +273,7 @@ Save: lda regbank,y
|
|||||||
; Initialize the output counter in the output descriptor to zero
|
; Initialize the output counter in the output descriptor to zero
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (OutData)
|
sta (OutData)
|
||||||
ldy #$01
|
ldy #$01
|
||||||
sta (OutData),y
|
sta (OutData),y
|
||||||
@@ -353,7 +352,7 @@ MainLoop:
|
|||||||
sta (c_sp),y
|
sta (c_sp),y
|
||||||
dey
|
dey
|
||||||
lda FCount
|
lda FCount
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (c_sp)
|
sta (c_sp)
|
||||||
.else
|
.else
|
||||||
sta (c_sp),y
|
sta (c_sp),y
|
||||||
@@ -570,7 +569,7 @@ CheckCount:
|
|||||||
jsr GetIntArg
|
jsr GetIntArg
|
||||||
sta ptr1
|
sta ptr1
|
||||||
stx ptr1+1 ; Get user supplied pointer
|
stx ptr1+1 ; Get user supplied pointer
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (OutData) ; Low byte of OutData->ccount
|
lda (OutData) ; Low byte of OutData->ccount
|
||||||
sta (ptr1)
|
sta (ptr1)
|
||||||
ldy #1
|
ldy #1
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
.include "time.inc"
|
.include "time.inc"
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
__time_t_to_tm:
|
__time_t_to_tm:
|
||||||
; Divide number of seconds since epoch, in ptr1:sreg,
|
; Divide number of seconds since epoch, in ptr1:sreg,
|
||||||
; by 86400 to get the number of days since epoch, and
|
; by 86400 to get the number of days since epoch, and
|
||||||
@@ -80,7 +78,7 @@ __time_t_to_tm:
|
|||||||
|
|
||||||
; Zero the two high bytes of the divisor and the high byte
|
; Zero the two high bytes of the divisor and the high byte
|
||||||
; of the dividend.
|
; of the dividend.
|
||||||
.if .cpu .bitand CPU_ISET_65SC02
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz ptr4
|
stz ptr4
|
||||||
stz ptr4+1
|
stz ptr4+1
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
.importzp ptr1
|
.importzp ptr1
|
||||||
.include "time.inc"
|
.include "time.inc"
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Special values
|
; Special values
|
||||||
|
|
||||||
@@ -24,7 +22,7 @@ MAX_BUF_LEN = 38
|
|||||||
|
|
||||||
_asctime:
|
_asctime:
|
||||||
; Backup timep
|
; Backup timep
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_PUSHXY)
|
||||||
pha
|
pha
|
||||||
phx
|
phx
|
||||||
.else
|
.else
|
||||||
@@ -48,7 +46,7 @@ _asctime:
|
|||||||
jsr pushax
|
jsr pushax
|
||||||
|
|
||||||
; Restore timep
|
; Restore timep
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_PUSHXY)
|
||||||
plx
|
plx
|
||||||
pla
|
pla
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
.include "errno.inc"
|
.include "errno.inc"
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|
||||||
.proc _atexit
|
.proc _atexit
|
||||||
@@ -41,7 +39,7 @@
|
|||||||
jsr ___seterrno
|
jsr ___seterrno
|
||||||
ldx #$FF ; Return -1
|
ldx #$FF ; Return -1
|
||||||
txa
|
txa
|
||||||
rts
|
Exit: rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
@@ -54,7 +52,7 @@
|
|||||||
.proc doatexit
|
.proc doatexit
|
||||||
|
|
||||||
ldy exitfunc_index ; Get index
|
ldy exitfunc_index ; Get index
|
||||||
beq @L9 ; Jump if done
|
beq _atexit::Exit ; Jump if done
|
||||||
dey
|
dey
|
||||||
lda exitfunc_table,y
|
lda exitfunc_table,y
|
||||||
tax
|
tax
|
||||||
@@ -62,14 +60,12 @@
|
|||||||
lda exitfunc_table,y
|
lda exitfunc_table,y
|
||||||
sty exitfunc_index
|
sty exitfunc_index
|
||||||
jsr callax ; Call the function
|
jsr callax ; Call the function
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_BRA8)
|
||||||
bra doatexit
|
bra doatexit
|
||||||
.else
|
.else
|
||||||
jmp doatexit ; Next one
|
jmp doatexit ; Next one
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
@L9: rts
|
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
.include "stdio.inc"
|
.include "stdio.inc"
|
||||||
.include "_file.inc"
|
.include "_file.inc"
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
_fgetc:
|
_fgetc:
|
||||||
sta ptr1
|
sta ptr1
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
@@ -22,7 +20,7 @@ _fgetc:
|
|||||||
jsr checkferror
|
jsr checkferror
|
||||||
bne ret_eof
|
bne ret_eof
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_BITIMM)
|
||||||
bit #_FPUSHBACK ; Check for pushed back char
|
bit #_FPUSHBACK ; Check for pushed back char
|
||||||
beq do_read
|
beq do_read
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -14,12 +14,10 @@
|
|||||||
.include "stdio.inc"
|
.include "stdio.inc"
|
||||||
.include "_file.inc"
|
.include "_file.inc"
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
terminate_ptr:
|
terminate_ptr:
|
||||||
lda #$00
|
lda #$00
|
||||||
tax
|
tax
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (ptr4)
|
sta (ptr4)
|
||||||
.else
|
.else
|
||||||
tay
|
tay
|
||||||
@@ -41,7 +39,7 @@ _fgets:
|
|||||||
sta buf
|
sta buf
|
||||||
stx buf+1
|
stx buf+1
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz didread
|
stz didread
|
||||||
.else
|
.else
|
||||||
lda #$00 ; We have read nothing yet
|
lda #$00 ; We have read nothing yet
|
||||||
@@ -79,7 +77,7 @@ read_loop:
|
|||||||
ldy #$01
|
ldy #$01
|
||||||
sty didread ; We read at least one char
|
sty didread ; We read at least one char
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (ptr4)
|
sta (ptr4)
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
.include "_file.inc"
|
.include "_file.inc"
|
||||||
|
|
||||||
.macpack generic
|
.macpack generic
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Code
|
; Code
|
||||||
@@ -48,7 +47,7 @@
|
|||||||
|
|
||||||
ldy #_FILE::f_flags
|
ldy #_FILE::f_flags
|
||||||
lda (file),y
|
lda (file),y
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_BITIMM)
|
||||||
bit #_FOPEN ; Is the file open?
|
bit #_FOPEN ; Is the file open?
|
||||||
.else
|
.else
|
||||||
and #_FOPEN ; Is the file open?
|
and #_FOPEN ; Is the file open?
|
||||||
@@ -57,7 +56,7 @@
|
|||||||
|
|
||||||
; Check if the stream is in an error state
|
; Check if the stream is in an error state
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_BITIMM)
|
||||||
bit #_FERROR
|
bit #_FERROR
|
||||||
.else
|
.else
|
||||||
lda (file),y ; get file->f_flags again
|
lda (file),y ; get file->f_flags again
|
||||||
@@ -74,17 +73,15 @@
|
|||||||
|
|
||||||
; Remember if we have a pushed back character and reset the flag.
|
; Remember if we have a pushed back character and reset the flag.
|
||||||
|
|
||||||
@L2: .if (.cpu .bitand ::CPU_ISET_65SC02)
|
@L2: .if .cap(CPU_HAS_BITIMM)
|
||||||
ldx #$00
|
ldx #$00
|
||||||
bit #_FPUSHBACK
|
bit #_FPUSHBACK
|
||||||
|
beq @L3
|
||||||
.else
|
.else
|
||||||
tax ; X = 0
|
tax ; X = 0
|
||||||
lda (file),y
|
lda (file),y
|
||||||
and #_FPUSHBACK
|
and #_FPUSHBACK
|
||||||
.endif
|
|
||||||
beq @L3
|
beq @L3
|
||||||
|
|
||||||
.if (.not .cpu .bitand ::CPU_ISET_65SC02)
|
|
||||||
lda (file),y
|
lda (file),y
|
||||||
.endif
|
.endif
|
||||||
and #<~_FPUSHBACK
|
and #<~_FPUSHBACK
|
||||||
@@ -135,7 +132,7 @@
|
|||||||
; Copy the buffer pointer into ptr1, and increment the pointer value passed
|
; Copy the buffer pointer into ptr1, and increment the pointer value passed
|
||||||
; to read() by one, so read() starts to store data at buf+1.
|
; to read() by one, so read() starts to store data at buf+1.
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
sta ptr1
|
sta ptr1
|
||||||
add #1
|
add #1
|
||||||
@@ -159,7 +156,7 @@
|
|||||||
|
|
||||||
ldy #_FILE::f_pushback
|
ldy #_FILE::f_pushback
|
||||||
lda (file),y
|
lda (file),y
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (ptr1) ; *buf = file->f_pushback;
|
sta (ptr1) ; *buf = file->f_pushback;
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
.include "errno.inc"
|
.include "errno.inc"
|
||||||
.include "_file.inc"
|
.include "_file.inc"
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Code
|
; Code
|
||||||
|
|
||||||
@@ -34,7 +32,7 @@
|
|||||||
|
|
||||||
ldy #_FILE::f_flags
|
ldy #_FILE::f_flags
|
||||||
lda (ptr1),y
|
lda (ptr1),y
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_BITIMM)
|
||||||
bit #_FOPEN
|
bit #_FOPEN
|
||||||
.else
|
.else
|
||||||
and #_FOPEN ; Is the file open?
|
and #_FOPEN ; Is the file open?
|
||||||
@@ -50,7 +48,7 @@
|
|||||||
|
|
||||||
; Check if the stream is in an error state
|
; Check if the stream is in an error state
|
||||||
|
|
||||||
@L2: .if (.not .cpu .bitand ::CPU_ISET_65SC02)
|
@L2: .if .not .cap(CPU_HAS_BITIMM)
|
||||||
lda (ptr1),y ; get file->f_flags again
|
lda (ptr1),y ; get file->f_flags again
|
||||||
.endif
|
.endif
|
||||||
and #_FERROR
|
and #_FERROR
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
.import __hextab, __longminstr
|
.import __hextab, __longminstr
|
||||||
.importzp sreg, ptr1, ptr2, ptr3, tmp1
|
.importzp sreg, ptr1, ptr2, ptr3, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
;
|
;
|
||||||
@@ -64,7 +62,7 @@ L2: txa ; get high byte
|
|||||||
bpl ultoa
|
bpl ultoa
|
||||||
lda #'-'
|
lda #'-'
|
||||||
|
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (ptr2)
|
sta (ptr2)
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
.export _strcat
|
.export _strcat
|
||||||
.import popax
|
.import popax
|
||||||
.importzp ptr1, ptr2, tmp3
|
.importzp ptr1, ptr2, tmp3
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
_strcat:
|
_strcat:
|
||||||
sta ptr1 ; Save src
|
sta ptr1 ; Save src
|
||||||
@@ -16,7 +15,7 @@ _strcat:
|
|||||||
jsr popax ; Get dest
|
jsr popax ; Get dest
|
||||||
sta tmp3 ; Remember for function return
|
sta tmp3 ; Remember for function return
|
||||||
tay
|
tay
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz ptr2
|
stz ptr2
|
||||||
.else
|
.else
|
||||||
lda #0
|
lda #0
|
||||||
|
|||||||
@@ -8,14 +8,13 @@
|
|||||||
.export _strchr
|
.export _strchr
|
||||||
.import popax
|
.import popax
|
||||||
.importzp ptr1, tmp1
|
.importzp ptr1, tmp1
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
_strchr:
|
_strchr:
|
||||||
sta tmp1 ; Save c
|
sta tmp1 ; Save c
|
||||||
jsr popax ; get s
|
jsr popax ; get s
|
||||||
tay ; low byte of pointer to y
|
tay ; low byte of pointer to y
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz ptr1
|
stz ptr1
|
||||||
.else
|
.else
|
||||||
lda #0
|
lda #0
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
.import _strlen_ptr4, _malloc, _memcpy, pushax
|
.import _strlen_ptr4, _malloc, _memcpy, pushax
|
||||||
.export _strdup
|
.export _strdup
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
_strdup:
|
_strdup:
|
||||||
; Get length (and store source in ptr4)
|
; Get length (and store source in ptr4)
|
||||||
sta ptr4
|
sta ptr4
|
||||||
@@ -22,7 +20,7 @@ _strdup:
|
|||||||
jsr _strlen_ptr4 ; strlen may increment
|
jsr _strlen_ptr4 ; strlen may increment
|
||||||
|
|
||||||
; Add null byte for terminator
|
; Add null byte for terminator
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_INA)
|
||||||
inc a
|
inc a
|
||||||
.else
|
.else
|
||||||
clc
|
clc
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
.export _strncat
|
.export _strncat
|
||||||
.import popax, popptr1
|
.import popax, popptr1
|
||||||
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
|
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
_strncat:
|
_strncat:
|
||||||
inx
|
inx
|
||||||
@@ -24,7 +23,7 @@ _strncat:
|
|||||||
stx ptr3+1
|
stx ptr3+1
|
||||||
stx ptr2+1
|
stx ptr2+1
|
||||||
tay ; low byte as offset in Y
|
tay ; low byte as offset in Y
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz ptr2
|
stz ptr2
|
||||||
.else
|
.else
|
||||||
ldx #0
|
ldx #0
|
||||||
|
|||||||
@@ -8,13 +8,12 @@
|
|||||||
.export _cputsxy, _cputs
|
.export _cputsxy, _cputs
|
||||||
.import gotoxy, _cputc
|
.import gotoxy, _cputc
|
||||||
.importzp ptr1, tmp1
|
.importzp ptr1, tmp1
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
_cputsxy:
|
_cputsxy:
|
||||||
sta ptr1 ; Save s for later
|
sta ptr1 ; Save s for later
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
jsr gotoxy ; Set cursor, pop x and y
|
jsr gotoxy ; Set cursor, pop x and y
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_BRA8)
|
||||||
bra L0 ; Same as cputs...
|
bra L0 ; Same as cputs...
|
||||||
.else
|
.else
|
||||||
jmp L0 ; Same as cputs...
|
jmp L0 ; Same as cputs...
|
||||||
@@ -24,7 +23,7 @@ _cputs: sta ptr1 ; Save s
|
|||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
|
|
||||||
L0:
|
L0:
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (ptr1) ; (5)
|
lda (ptr1) ; (5)
|
||||||
.else
|
.else
|
||||||
ldy #0 ; (2)
|
ldy #0 ; (2)
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
.import screensize
|
.import screensize
|
||||||
.importzp ptr1, ptr2
|
.importzp ptr1, ptr2
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
.proc _screensize
|
.proc _screensize
|
||||||
|
|
||||||
sta ptr2 ; Store the y pointer
|
sta ptr2 ; Store the y pointer
|
||||||
@@ -20,7 +18,7 @@
|
|||||||
jsr screensize ; Get screensize into X/Y
|
jsr screensize ; Get screensize into X/Y
|
||||||
tya ; Get Y size into A
|
tya ; Get Y size into A
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (ptr2)
|
sta (ptr2)
|
||||||
txa
|
txa
|
||||||
sta (ptr1)
|
sta (ptr1)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
.importzp c_sp, ptr1, ptr2, ptr3, tmp1
|
.importzp c_sp, ptr1, ptr2, ptr3, tmp1
|
||||||
|
|
||||||
.macpack generic
|
.macpack generic
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ out: jsr popax ; count
|
|||||||
|
|
||||||
; Loop outputting characters
|
; Loop outputting characters
|
||||||
|
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND, CPU_HAS_BRA8)
|
||||||
|
|
||||||
@L1: dec outdesc+6
|
@L1: dec outdesc+6
|
||||||
beq @L4
|
beq @L4
|
||||||
|
|||||||
@@ -11,14 +11,12 @@
|
|||||||
.export tosadda0, tosaddax
|
.export tosadda0, tosaddax
|
||||||
.importzp c_sp, tmp1
|
.importzp c_sp, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosadda0:
|
tosadda0:
|
||||||
ldx #0
|
ldx #0
|
||||||
tosaddax:
|
tosaddax:
|
||||||
clc ; (2)
|
clc ; (2)
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
|
|
||||||
adc (c_sp) ; (7)
|
adc (c_sp) ; (7)
|
||||||
tay ; (9)
|
tay ; (9)
|
||||||
|
|||||||
@@ -8,12 +8,10 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, ptr4
|
.importzp c_sp, ptr4
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosanda0:
|
tosanda0:
|
||||||
ldx #$00
|
ldx #$00
|
||||||
tosandax:
|
tosandax:
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
and (c_sp) ; 65SC02 version, saves 2 cycles and 1 byte
|
and (c_sp) ; 65SC02 version, saves 2 cycles and 1 byte
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
|
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
|
||||||
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
|
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; --------------------------------------------------------------------------
|
; --------------------------------------------------------------------------
|
||||||
; Initialize library modules
|
; Initialize library modules
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,10 @@
|
|||||||
.export incax1
|
.export incax1
|
||||||
|
|
||||||
.macpack generic
|
.macpack generic
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
.proc incax1
|
.proc incax1
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_INA)
|
||||||
ina ; 65C02 version
|
ina ; 65C02 version
|
||||||
bne @L9
|
bne @L9
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
.export popax, incsp2
|
.export popax, incsp2
|
||||||
.importzp c_sp
|
.importzp c_sp
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; Pop a/x from stack. This function will run directly into incsp2
|
; Pop a/x from stack. This function will run directly into incsp2
|
||||||
|
|
||||||
.proc popax
|
.proc popax
|
||||||
@@ -16,7 +14,7 @@
|
|||||||
ldy #1
|
ldy #1
|
||||||
lda (c_sp),y ; get hi byte
|
lda (c_sp),y ; get hi byte
|
||||||
tax ; into x
|
tax ; into x
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp) ; get lo byte
|
lda (c_sp) ; get lo byte
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, sreg, tmp1
|
.importzp c_sp, sreg, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; EAX = TOS + EAX
|
; EAX = TOS + EAX
|
||||||
|
|
||||||
tosadd0ax:
|
tosadd0ax:
|
||||||
@@ -19,7 +17,7 @@ tosadd0ax:
|
|||||||
|
|
||||||
tosaddeax:
|
tosaddeax:
|
||||||
clc
|
clc
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
adc (c_sp) ; 65SC02 version - saves 2 cycles
|
adc (c_sp) ; 65SC02 version - saves 2 cycles
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
.export laddeq1, laddeqa, laddeq
|
.export laddeq1, laddeqa, laddeq
|
||||||
.importzp sreg, ptr1, tmp1
|
.importzp sreg, ptr1, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
laddeq1:
|
laddeq1:
|
||||||
lda #$01
|
lda #$01
|
||||||
|
|
||||||
@@ -24,7 +22,7 @@ laddeqa:
|
|||||||
laddeq: sty ptr1+1 ; Store high byte of address
|
laddeq: sty ptr1+1 ; Store high byte of address
|
||||||
clc
|
clc
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
adc (ptr1)
|
adc (ptr1)
|
||||||
sta (ptr1)
|
sta (ptr1)
|
||||||
ldy #$01 ; Address byte 1
|
ldy #$01 ; Address byte 1
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, sreg, tmp1
|
.importzp c_sp, sreg, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosand0ax:
|
tosand0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
@@ -22,7 +20,7 @@ tosand0ax:
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
tosandeax:
|
tosandeax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
and (c_sp) ; byte 0
|
and (c_sp) ; byte 0
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
.export ldau00sp, ldau0ysp
|
.export ldau00sp, ldau0ysp
|
||||||
.importzp c_sp, ptr1
|
.importzp c_sp, ptr1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
ldau00sp:
|
ldau00sp:
|
||||||
ldy #1
|
ldy #1
|
||||||
ldau0ysp:
|
ldau0ysp:
|
||||||
@@ -18,7 +16,7 @@ ldau0ysp:
|
|||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
sta ptr1
|
sta ptr1
|
||||||
ldx #0
|
ldx #0
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (ptr1) ; Save one cycle for the C02
|
lda (ptr1) ; Save one cycle for the C02
|
||||||
.else
|
.else
|
||||||
lda (ptr1,x)
|
lda (ptr1,x)
|
||||||
|
|||||||
@@ -14,8 +14,6 @@
|
|||||||
.import addysp
|
.import addysp
|
||||||
.importzp c_sp
|
.importzp c_sp
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
leave00:
|
leave00:
|
||||||
lda #0
|
lda #0
|
||||||
leave0: ldx #0
|
leave0: ldx #0
|
||||||
@@ -28,7 +26,7 @@ leavey0:
|
|||||||
leavey:
|
leavey:
|
||||||
jsr addysp ; drop stack frame
|
jsr addysp ; drop stack frame
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
|
|
||||||
leave: tay ; save A a sec
|
leave: tay ; save A a sec
|
||||||
lda (c_sp) ; that's the pushed arg size
|
lda (c_sp) ; that's the pushed arg size
|
||||||
|
|||||||
@@ -11,10 +11,8 @@
|
|||||||
.import poplsargs, udiv32, negeax
|
.import poplsargs, udiv32, negeax
|
||||||
.importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4
|
.importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosmod0ax:
|
tosmod0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,11 +9,9 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4
|
.importzp c_sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosmul0ax:
|
tosmul0ax:
|
||||||
tosumul0ax:
|
tosumul0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
@@ -26,7 +24,7 @@ tosmuleax:
|
|||||||
tosumuleax:
|
tosumuleax:
|
||||||
mul32: sta ptr1
|
mul32: sta ptr1
|
||||||
stx ptr1+1 ; op2 now in ptr1/sreg
|
stx ptr1+1 ; op2 now in ptr1/sreg
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, sreg, tmp1
|
.importzp c_sp, sreg, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosor0ax:
|
tosor0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
@@ -22,7 +20,7 @@ tosor0ax:
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
tosoreax:
|
tosoreax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
ora (c_sp)
|
ora (c_sp)
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
.import incsp4
|
.import incsp4
|
||||||
.importzp c_sp, sreg
|
.importzp c_sp, sreg
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
popeax: ldy #3
|
popeax: ldy #3
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
sta sreg+1
|
sta sreg+1
|
||||||
@@ -20,7 +18,7 @@ popeax: ldy #3
|
|||||||
dey
|
dey
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
tax
|
tax
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
|
|||||||
@@ -12,13 +12,11 @@
|
|||||||
.import decsp4
|
.import decsp4
|
||||||
.importzp c_sp, sreg
|
.importzp c_sp, sreg
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
pushl0:
|
pushl0:
|
||||||
lda #0
|
lda #0
|
||||||
tax
|
tax
|
||||||
push0ax:
|
push0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
@@ -39,7 +37,7 @@ pusheax:
|
|||||||
txa
|
txa
|
||||||
sta (c_sp),y
|
sta (c_sp),y
|
||||||
pla
|
pla
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (c_sp)
|
sta (c_sp)
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, sreg, tmp1
|
.importzp c_sp, sreg, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosrsub0ax:
|
tosrsub0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
@@ -26,7 +24,7 @@ tosrsub0ax:
|
|||||||
|
|
||||||
tosrsubeax:
|
tosrsubeax:
|
||||||
sec
|
sec
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sbc (c_sp)
|
sbc (c_sp)
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -11,10 +11,8 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, sreg
|
.importzp c_sp, sreg
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tossub0ax:
|
tossub0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
@@ -26,7 +24,7 @@ tossub0ax:
|
|||||||
tossubeax:
|
tossubeax:
|
||||||
sec
|
sec
|
||||||
eor #$FF
|
eor #$FF
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
adc (c_sp) ; 65SC02 version - saves 2 cycles
|
adc (c_sp) ; 65SC02 version - saves 2 cycles
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
.export lsubeq1, lsubeqa, lsubeq
|
.export lsubeq1, lsubeqa, lsubeq
|
||||||
.importzp sreg, ptr1
|
.importzp sreg, ptr1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
lsubeq1:
|
lsubeq1:
|
||||||
lda #$01
|
lda #$01
|
||||||
|
|
||||||
@@ -25,7 +23,7 @@ lsubeq: sty ptr1+1 ; Store high byte of address
|
|||||||
|
|
||||||
sec
|
sec
|
||||||
eor #$FF
|
eor #$FF
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
adc (ptr1) ; Subtract byte 0
|
adc (ptr1) ; Subtract byte 0
|
||||||
sta (ptr1)
|
sta (ptr1)
|
||||||
ldy #$01 ; Address byte 1
|
ldy #$01 ; Address byte 1
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
|
.importzp c_sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosudiv0ax:
|
tosudiv0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
@@ -38,7 +36,7 @@ getlop: sta ptr3 ; Put right operand in place
|
|||||||
lda sreg+1
|
lda sreg+1
|
||||||
sta ptr4+1
|
sta ptr4+1
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
.import getlop, udiv32
|
.import getlop, udiv32
|
||||||
.importzp sreg, tmp3, tmp4, ptr2
|
.importzp sreg, tmp3, tmp4, ptr2
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosumod0ax:
|
tosumod0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, sreg, tmp1
|
.importzp c_sp, sreg, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosxor0ax:
|
tosxor0ax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz sreg
|
stz sreg
|
||||||
stz sreg+1
|
stz sreg+1
|
||||||
.else
|
.else
|
||||||
@@ -22,7 +20,7 @@ tosxor0ax:
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
tosxoreax:
|
tosxoreax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
eor (c_sp) ; byte 0
|
eor (c_sp) ; byte 0
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,12 +9,10 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, tmp1
|
.importzp c_sp, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosora0:
|
tosora0:
|
||||||
ldx #$00
|
ldx #$00
|
||||||
tosorax:
|
tosorax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
ora (c_sp)
|
ora (c_sp)
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -7,11 +7,9 @@
|
|||||||
.export popa
|
.export popa
|
||||||
.importzp c_sp
|
.importzp c_sp
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
.proc popa
|
.proc popa
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
.else
|
.else
|
||||||
ldy #0 ; (2)
|
ldy #0 ; (2)
|
||||||
|
|||||||
@@ -8,14 +8,12 @@
|
|||||||
.import incsp2
|
.import incsp2
|
||||||
.importzp c_sp, ptr1
|
.importzp c_sp, ptr1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
.proc popptr1 ; 14 bytes (four usages = at least 2 bytes saved)
|
.proc popptr1 ; 14 bytes (four usages = at least 2 bytes saved)
|
||||||
ldy #1
|
ldy #1
|
||||||
lda (c_sp),y ; get hi byte
|
lda (c_sp),y ; get hi byte
|
||||||
sta ptr1+1 ; into ptr hi
|
sta ptr1+1 ; into ptr hi
|
||||||
dey ; dey even for for 65C02 here to have Y=0 at exit!
|
dey ; dey even for for 65C02 here to have Y=0 at exit!
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp) ; get lo byte
|
lda (c_sp) ; get lo byte
|
||||||
.else
|
.else
|
||||||
lda (c_sp),y ; get lo byte
|
lda (c_sp),y ; get lo byte
|
||||||
|
|||||||
@@ -8,14 +8,12 @@
|
|||||||
.import incsp2
|
.import incsp2
|
||||||
.importzp c_sp, sreg
|
.importzp c_sp, sreg
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
popsreg:
|
popsreg:
|
||||||
pha ; save A
|
pha ; save A
|
||||||
ldy #1
|
ldy #1
|
||||||
lda (c_sp),y ; get hi byte
|
lda (c_sp),y ; get hi byte
|
||||||
sta sreg+1 ; store it
|
sta sreg+1 ; store it
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp) ; get lo byte
|
lda (c_sp) ; get lo byte
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
.export pusha0sp, pushaysp, pusha
|
.export pusha0sp, pushaysp, pusha
|
||||||
.importzp c_sp
|
.importzp c_sp
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; Beware: The optimizer knows about this function!
|
; Beware: The optimizer knows about this function!
|
||||||
|
|
||||||
pusha0sp:
|
pusha0sp:
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
.export push0, pusha0, pushax
|
.export push0, pusha0, pushax
|
||||||
.importzp c_sp
|
.importzp c_sp
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
push0: lda #0
|
push0: lda #0
|
||||||
pusha0: ldx #0
|
pusha0: ldx #0
|
||||||
|
|
||||||
@@ -31,7 +29,7 @@ pusha0: ldx #0
|
|||||||
sta (c_sp),y ; (27)
|
sta (c_sp),y ; (27)
|
||||||
pla ; (31)
|
pla ; (31)
|
||||||
dey ; (33)
|
dey ; (33)
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (c_sp) ; (37)
|
sta (c_sp) ; (37)
|
||||||
.else
|
.else
|
||||||
sta (c_sp),y ; (38)
|
sta (c_sp),y ; (38)
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
.import pushax
|
.import pushax
|
||||||
.importzp ptr1
|
.importzp ptr1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
pushbidx:
|
pushbidx:
|
||||||
sty ptr1
|
sty ptr1
|
||||||
clc
|
clc
|
||||||
@@ -19,7 +17,7 @@ pushbidx:
|
|||||||
pushb: sta ptr1
|
pushb: sta ptr1
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
ldx #0 ; Load index/high byte
|
ldx #0 ; Load index/high byte
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (ptr1) ; Save one cycle for the C02
|
lda (ptr1) ; Save one cycle for the C02
|
||||||
.else
|
.else
|
||||||
lda (ptr1,x)
|
lda (ptr1,x)
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, tmp1
|
.importzp c_sp, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
;
|
;
|
||||||
; AX = AX - TOS
|
; AX = AX - TOS
|
||||||
;
|
;
|
||||||
@@ -19,7 +17,7 @@ tosrsuba0:
|
|||||||
ldx #0
|
ldx #0
|
||||||
tosrsubax:
|
tosrsubax:
|
||||||
sec
|
sec
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sbc (c_sp)
|
sbc (c_sp)
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
.import popax
|
.import popax
|
||||||
.importzp tmp1
|
.importzp tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosshlax:
|
tosshlax:
|
||||||
tosaslax:
|
tosaslax:
|
||||||
sta tmp1 ; Save shift count
|
sta tmp1 ; Save shift count
|
||||||
@@ -55,7 +53,7 @@ L2: pla
|
|||||||
|
|
||||||
; Shift count is exactly 8
|
; Shift count is exactly 8
|
||||||
|
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_PUSHXY)
|
||||||
L3: plx ; Low byte from stack into X
|
L3: plx ; Low byte from stack into X
|
||||||
rts ; A is already zero
|
rts ; A is already zero
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
.import incsp2
|
.import incsp2
|
||||||
.importzp c_sp, tmp1, ptr1
|
.importzp c_sp, tmp1, ptr1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
.proc staxspidx
|
.proc staxspidx
|
||||||
|
|
||||||
sty tmp1 ; Save Y
|
sty tmp1 ; Save Y
|
||||||
@@ -18,7 +16,7 @@
|
|||||||
ldy #1
|
ldy #1
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
sta ptr1+1
|
sta ptr1+1
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
; Use macros for better readability
|
; Use macros for better readability
|
||||||
.macpack generic
|
.macpack generic
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
@@ -39,7 +38,7 @@
|
|||||||
lda c_sp+1
|
lda c_sp+1
|
||||||
sta initialsp+1
|
sta initialsp+1
|
||||||
sbc #>__STACKSIZE__
|
sbc #>__STACKSIZE__
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_INA)
|
||||||
ina ; Add 256 bytes safety area
|
ina ; Add 256 bytes safety area
|
||||||
.else
|
.else
|
||||||
add #1 ; Add 256 bytes safety area
|
add #1 ; Add 256 bytes safety area
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp
|
.importzp c_sp
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; AX = TOS - AX
|
; AX = TOS - AX
|
||||||
|
|
||||||
tossuba0:
|
tossuba0:
|
||||||
@@ -17,7 +15,7 @@ tossuba0:
|
|||||||
tossubax:
|
tossubax:
|
||||||
sec
|
sec
|
||||||
eor #$FF
|
eor #$FF
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
adc (c_sp)
|
adc (c_sp)
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
.export swapstk
|
.export swapstk
|
||||||
.importzp c_sp, ptr4
|
.importzp c_sp, ptr4
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
swapstk:
|
swapstk:
|
||||||
sta ptr4
|
sta ptr4
|
||||||
stx ptr4+1
|
stx ptr4+1
|
||||||
@@ -18,7 +16,7 @@ swapstk:
|
|||||||
tax
|
tax
|
||||||
lda ptr4+1
|
lda ptr4+1
|
||||||
sta (c_sp),y
|
sta (c_sp),y
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
tay
|
tay
|
||||||
lda ptr4
|
lda ptr4
|
||||||
|
|||||||
@@ -8,14 +8,12 @@
|
|||||||
.import incsp2
|
.import incsp2
|
||||||
.importzp c_sp
|
.importzp c_sp
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; Convert TOS from long to int by cutting of the high 16bit
|
; Convert TOS from long to int by cutting of the high 16bit
|
||||||
|
|
||||||
.proc tosint
|
.proc tosint
|
||||||
|
|
||||||
pha
|
pha
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
.import decsp2
|
.import decsp2
|
||||||
.importzp c_sp
|
.importzp c_sp
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
; Convert TOS from int to long
|
; Convert TOS from int to long
|
||||||
|
|
||||||
tosulong:
|
tosulong:
|
||||||
@@ -17,7 +15,7 @@ tosulong:
|
|||||||
jsr decsp2 ; Make room
|
jsr decsp2 ; Make room
|
||||||
ldy #2
|
ldy #2
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (c_sp) ; 65C02 version
|
sta (c_sp) ; 65C02 version
|
||||||
iny ; Y = 3
|
iny ; Y = 3
|
||||||
.else
|
.else
|
||||||
@@ -43,7 +41,7 @@ toslong:
|
|||||||
jsr decsp2 ; Make room
|
jsr decsp2 ; Make room
|
||||||
ldy #2
|
ldy #2
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
sta (c_sp) ; 65C02 version
|
sta (c_sp) ; 65C02 version
|
||||||
iny ; Y = 3
|
iny ; Y = 3
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;---------------------------------------------------------------------------
|
||||||
; 8x16 => 24 unsigned multiplication routine. Because the overhead for a
|
; 8x16 => 24 unsigned multiplication routine. Because the overhead for a
|
||||||
; 8x16 => 16 unsigned multiplication routine is small, we will tag it with
|
; 8x16 => 16 unsigned multiplication routine is small, we will tag it with
|
||||||
@@ -31,7 +29,7 @@ umul8x16r16:
|
|||||||
|
|
||||||
umul8x16r24m:
|
umul8x16r24m:
|
||||||
umul8x16r16m:
|
umul8x16r16m:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_STZ)
|
||||||
stz ptr1+1
|
stz ptr1+1
|
||||||
stz sreg
|
stz sreg
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,12 +9,10 @@
|
|||||||
.import addysp1
|
.import addysp1
|
||||||
.importzp c_sp, tmp1
|
.importzp c_sp, tmp1
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
tosxora0:
|
tosxora0:
|
||||||
ldx #$00
|
ldx #$00
|
||||||
tosxorax:
|
tosxorax:
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_ZPIND)
|
||||||
eor (c_sp)
|
eor (c_sp)
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
.import umul8x16r24
|
.import umul8x16r24
|
||||||
.import popa, popax
|
.import popa, popax
|
||||||
|
|
||||||
.macpack cpu
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
|
; void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
|
||||||
; unsigned char dir, unsigned char font);
|
; unsigned char dir, unsigned char font);
|
||||||
@@ -82,7 +80,7 @@ process_onedim:
|
|||||||
; Disallowing characters larger than 256 pixels, we just drop the high byte
|
; Disallowing characters larger than 256 pixels, we just drop the high byte
|
||||||
; and remember the low 16 bit as size in 8.8 format.
|
; and remember the low 16 bit as size in 8.8 format.
|
||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if .cap(CPU_HAS_PUSHXY)
|
||||||
phy ; Save Y
|
phy ; Save Y
|
||||||
jsr umul8x16r24
|
jsr umul8x16r24
|
||||||
ply ; Restore Y
|
ply ; Restore Y
|
||||||
|
|||||||
Reference in New Issue
Block a user