; sectnum_t - 16bit
;
- .export _dio_phys_to_log
- .export sectab_1541_l, sectab_1541_h ; for log_to_phys
- .import popax,__oserror
- .importzp ptr1,ptr2,ptr3,tmp1,tmp2,tmp3,tmp4
- .include "dio.inc"
- .include "geossym.inc"
- .include "const.inc"
-
-.proc _dio_phys_to_log
- sta ptr1
- stx ptr1+1 ; pointer to result
-
- jsr popax
- sta ptr2
- stx ptr2+1 ; pointer to input structure
-
- jsr popax
- sta ptr3
- stx ptr3+1 ; pointer to handle
-
- ldy #sst_flag
- lda (ptr3),y
- and #128
- beq _inv_hand ; handle not open or invalid
-
-
- ldy #diopp_head
- lda (ptr2),y
- bne _inv_data ; there is only head 0
- ldy #diopp_track
- lda (ptr2),y
- beq _inv_data ; there is no track 0
- sta tmp1
+ .export _dio_phys_to_log
+ .export sectab_1541_l, sectab_1541_h ; for log_to_phys
+ .import popax,__oserror
+ .importzp ptr1,ptr2,ptr3,tmp1,tmp2,tmp3,tmp4
+
+ .include "dio.inc"
+ .include "geossym.inc"
+ .include "const.inc"
+
+_dio_phys_to_log:
+ sta ptr1
+ stx ptr1+1 ; pointer to result
+
+ jsr popax
+ sta ptr2
+ stx ptr2+1 ; pointer to input structure
+
+ jsr popax
+ sta ptr3
+ stx ptr3+1 ; pointer to handle
+
+ ldy #sst_flag
+ lda (ptr3),y
+ and #128
+ beq _inv_hand ; handle not open or invalid
+
+
+ ldy #diopp_head
+ lda (ptr2),y
+ bne _inv_data ; there is only head 0
+ ldy #diopp_track
+ lda (ptr2),y
+ beq _inv_data ; there is no track 0
+ sta tmp1
iny
- lda (ptr2),y
- bne _inv_data ; there are no more than 256 tracks
- dec tmp1 ; normalize track to start from 0
- ldy #diopp_sector
- lda (ptr2),y
- sta tmp2
+ lda (ptr2),y
+ bne _inv_data ; there are no more than 256 tracks
+ dec tmp1 ; normalize track to start from 0
+ ldy #diopp_sector
+ lda (ptr2),y
+ sta tmp2
iny
- lda (ptr2),y
- bne _inv_data ; there are no more than 256 sectors
+ lda (ptr2),y
+ bne _inv_data ; there are no more than 256 sectors
; tmp1 (int) holds track+sector, translate it using device info
- ldy #sst_driveno
- lda (ptr3),y
+ ldy #sst_driveno
+ lda (ptr3),y
tay
- lda driveType,y
- and #%00000011 ; this is for RamDrive compatibility
- cmp #DRV_1541
- beq dio_cts1541
- cmp #DRV_1571
- beq dio_cts1571
- cmp #DRV_1581
- beq dio_cts1581
-
- lda #DEV_NOT_FOUND ; unknown device
- ldx #0
- beq ret
+ lda driveType,y
+ and #%00000011 ; this is for RamDrive compatibility
+ cmp #DRV_1541
+ beq dio_cts1541
+ cmp #DRV_1571
+ beq dio_cts1571
+ cmp #DRV_1581
+ beq dio_cts1581
+
+ lda #DEV_NOT_FOUND ; unknown device
+ ldx #0
+ beq ret
dio_ctsend:
- ldy #1
- lda tmp2
- sta (ptr1),y
+ ldy #1
+ lda tmp2
+ sta (ptr1),y
dey
- lda tmp1
- sta (ptr1),y
-
- ldx #0
+ lda tmp1
+ sta (ptr1),y
+
+ ldx #0
txa
-ret:
- sta __oserror
+ret:
+ sta __oserror
rts ; return success
; errors
_inv_data:
- lda #INV_TRACK
+ lda #INV_TRACK
.byte $2c
_inv_hand:
- lda #INCOMPATIBLE
- ldx #0
- beq ret
+ lda #INCOMPATIBLE
+ ldx #0
+ beq ret
; device-depended stuff, tmp1=track-1, tmp2=sector
bcs _inv_data
; mul40 by Christian Groessler
- sta tmp4
- asl a
- rol tmp3
- asl a
- rol tmp3 ; val * 4
- adc tmp4
- bcc L1
- inc tmp3 ; val * 5
-L1: asl a
- rol tmp3 ; val * 10
- asl a
- rol tmp3
- asl a
- rol tmp3 ; val * 40 = AX
- ldx tmp3
- sta tmp3
- stx tmp4
+ sta tmp4
+ asl a
+ rol tmp3
+ asl a
+ rol tmp3 ; val * 4
+ adc tmp4
+ bcc L1
+ inc tmp3 ; val * 5
+L1: asl a
+ rol tmp3 ; val * 10
+ asl a
+ rol tmp3
+ asl a
+ rol tmp3 ; val * 40 = AX
+ ldx tmp3
+ sta tmp3
+ stx tmp4
_nomult:
lda tmp2
sta tmp2
jmp dio_ctsend
-.endproc
-
.rodata
sectab_1541_l:
- .byte $00, $15, $2a, $3f, $54, $69, $7e, $93
- .byte $a8, $bd, $d2, $e7, $fc, $11, $26, $3b
- .byte $50, $65, $78, $8b, $9e, $b1, $c4, $d7
- .byte $ea, $fc, $0e, $20, $32, $44, $56, $67
- .byte $78, $89, $9a, $ab
+ .byte $00, $15, $2a, $3f, $54, $69, $7e, $93
+ .byte $a8, $bd, $d2, $e7, $fc, $11, $26, $3b
+ .byte $50, $65, $78, $8b, $9e, $b1, $c4, $d7
+ .byte $ea, $fc, $0e, $20, $32, $44, $56, $67
+ .byte $78, $89, $9a, $ab
sectab_1541_h:
- .byte $00, $00, $00, $00, $00, $00, $00, $00
- .byte $00, $00, $00, $00, $00, $01, $01, $01
- .byte $01, $01, $01, $01, $01, $01, $01, $01
- .byte $01, $01, $02, $02, $02, $02, $02, $02
- .byte $02, $02, $02, $02
+ .byte $00, $00, $00, $00, $00, $00, $00, $00
+ .byte $00, $00, $00, $00, $00, $01, $01, $01
+ .byte $01, $01, $01, $01, $01, $01, $01, $01
+ .byte $01, $01, $02, $02, $02, $02, $02, $02
+ .byte $02, $02, $02, $02
; dio_open sets given device as current and initializes disk
; dio_close does nothing special
- .export _dio_open, _dio_close
- .import __oserror, _OpenDisk
- .importzp ptr1, tmp1
- .include "dio.inc"
- .include "jumptab.inc"
- .include "geossym.inc"
- .include "const.inc"
+ .export _dio_open, _dio_close
+ .import __oserror, _OpenDisk
+ .importzp ptr1, tmp1
+
+ .include "dio.inc"
+ .include "jumptab.inc"
+ .include "geossym.inc"
+ .include "const.inc"
.bss
sectsizetab:
- .res 4 * sst_size ; this is hardcoded
+ .res 4 * sst_size ; this is hardcoded
.code
-.proc _dio_open
+_dio_open:
pha
tax
lda driveType,x ; check if there's a device
pla
tay ; drive #
- asl a ; make index from drive id
- asl a
+ asl a ; make index from drive id
+ asl a
tax
-
- lda #0
- sta sectsizetab+sst_sectsize,x
- lda #128
- sta sectsizetab+sst_flag,x ; set flag that drive is "open"
- lda #1
- sta sectsizetab+sst_sectsize+1,x
+
+ lda #0
+ sta sectsizetab+sst_sectsize,x
+ lda #128
+ sta sectsizetab+sst_flag,x ; set flag that drive is "open"
+ lda #1
+ sta sectsizetab+sst_sectsize+1,x
tya
- sta sectsizetab+sst_driveno,x
-
- stx tmp1
- lda #<sectsizetab
+ sta sectsizetab+sst_driveno,x
+
+ stx tmp1
+ lda #<sectsizetab
clc
- adc tmp1
- sta tmp1
- lda #>sectsizetab
- adc #0
+ adc tmp1
+ sta tmp1
+ lda #>sectsizetab
+ adc #0
tax
- lda tmp1
+ lda tmp1
rts
tax
rts
-.endproc
-
-.proc _dio_close
- sta ptr1
- stx ptr1+1
- lda #0
- ldy #sst_flag
- sta (ptr1),y
- sta __oserror ; success
+_dio_close:
+ sta ptr1
+ stx ptr1+1
+ lda #0
+ ldy #sst_flag
+ sta (ptr1),y
+ sta __oserror ; success
tax
rts ; return no error
-.endproc
; this function is used by dio_read and dio_write to fix parameters (secnum)
; this function calls SetDevice so that more than one drive can be used at once
- .import popax,pushax,_dio_log_to_phys
- .importzp ptr1
- .export dio_params,dio_secnum
- .include "geossym.inc"
- .include "jumptab.inc"
- .include "dio.inc"
+ .import popax,pushax,_dio_log_to_phys
+ .importzp ptr1
+ .export dio_params,dio_secnum
+
+ .include "geossym.inc"
+ .include "jumptab.inc"
+ .include "dio.inc"
.bss
-dio_secnum: .res 2
+
+dio_secnum:
+ .res 2
.code
-.proc dio_params
+dio_params:
sta r4L
stx r4H
lda #<r1L
ldx #>r1H
jmp _dio_log_to_phys
-
-.endproc
; sectnum_t - 16bit
;
- .import dio_params, __oserror
- .export _dio_read
- .include "geossym.inc"
- .include "jumptab.inc"
+ .import dio_params, __oserror
+ .export _dio_read
-.proc _dio_read
+ .include "geossym.inc"
+ .include "jumptab.inc"
+_dio_read:
jsr dio_params
jsr ReadBlock
stx __oserror
txa
rts
-
-.endproc
; sectnum_t - 16bit
;
- .export _dio_log_to_phys
- .importzp ptr1,ptr2,ptr3,tmp1,tmp2
- .import popax,__oserror
- .import sectab_1541_l, sectab_1541_h
- .include "dio.inc"
- .include "geossym.inc"
- .include "const.inc"
+ .export _dio_log_to_phys
+ .importzp ptr1,ptr2,ptr3,tmp1,tmp2
+ .import popax,__oserror
+ .import sectab_1541_l, sectab_1541_h
-.proc _dio_log_to_phys
+ .include "dio.inc"
+ .include "geossym.inc"
+ .include "const.inc"
+_dio_log_to_phys:
; check device type
- sta ptr1
- stx ptr1+1 ; pointer to result (struct dio_phys_pos)
-
- jsr popax
- sta ptr2
- stx ptr2+1 ; pointer to input structure (pointer to int)
-
- jsr popax
- sta ptr3
- stx ptr3+1 ; pointer to handle
-
- ldy #sst_flag
- lda (ptr3),y
- and #128
- beq _inv_hand ; handle not open or invalid
+ sta ptr1
+ stx ptr1+1 ; pointer to result (struct dio_phys_pos)
+
+ jsr popax
+ sta ptr2
+ stx ptr2+1 ; pointer to input structure (pointer to int)
+
+ jsr popax
+ sta ptr3
+ stx ptr3+1 ; pointer to handle
+
+ ldy #sst_flag
+ lda (ptr3),y
+ and #128
+ beq _inv_hand ; handle not open or invalid
; fill in all we have
- ldy #diopp_head
- lda #0 ; head 0
- sta (ptr1),y
- ldy #diopp_track+1
- sta (ptr1),y ; track <256
- ldy #diopp_sector+1
- sta (ptr1),y ; sector <256
-
- ldy #0
- lda (ptr2),y
- sta tmp1
- iny
- lda (ptr2),y
- sta tmp2
+ ldy #diopp_head
+ lda #0 ; head 0
+ sta (ptr1),y
+ ldy #diopp_track+1
+ sta (ptr1),y ; track <256
+ ldy #diopp_sector+1
+ sta (ptr1),y ; sector <256
+
+ ldy #0
+ lda (ptr2),y
+ sta tmp1
+ iny
+ lda (ptr2),y
+ sta tmp2
; get drive info
- ldy #sst_driveno
- lda (ptr3),y
- tay
- lda driveType,y
- and #%00000011 ; this is for RamDrive compatibility
- cmp #DRV_1541
- beq dio_stc1541
- cmp #DRV_1571
- beq dio_stc1571
- cmp #DRV_1581
- beq dio_stc1581
-
- lda #DEV_NOT_FOUND ; unknown device
- ldx #0
- beq _ret
+ ldy #sst_driveno
+ lda (ptr3),y
+ tay
+ lda driveType,y
+ and #%00000011 ; this is for RamDrive compatibility
+ cmp #DRV_1541
+ beq dio_stc1541
+ cmp #DRV_1571
+ beq dio_stc1571
+ cmp #DRV_1581
+ beq dio_stc1581
+
+ lda #DEV_NOT_FOUND ; unknown device
+ ldx #0
+ beq _ret
dio_stcend:
- ldy #diopp_track
- lda tmp1
- sta (ptr1),y
- ldy #diopp_sector
- lda tmp2
- sta (ptr1),y
-
- ldx #0
- txa
-_ret:
- sta __oserror
+ ldy #diopp_track
+ lda tmp1
+ sta (ptr1),y
+ ldy #diopp_sector
+ lda tmp2
+ sta (ptr1),y
+
+ ldx #0
+ txa
+_ret:
+ sta __oserror
rts ; return success
; errors
_inv_data:
- lda #INV_TRACK
+ lda #INV_TRACK
.byte $2c
_inv_hand:
- lda #INCOMPATIBLE
- ldx #0
- beq _ret
+ lda #INCOMPATIBLE
+ ldx #0
+ beq _ret
dio_stc1541:
; if 1541:
; - compare with table to find track
; - subtract and find sector
- ldx #0 ; index=(track-1)
+ ldx #0 ; index=(track-1)
_loop41:
- lda tmp2
- cmp sectab_1541_h+1,x
- bne _nxt
- lda tmp1
- cmp sectab_1541_l+1,x
- bcc _found
-_nxt: inx
- cpx #35
- bne _loop41
- beq _inv_data
-
-_found:
- lda tmp1
- sec
- sbc sectab_1541_l,x
- sta tmp2
-_fndend:
- inx
- stx tmp1
- jmp dio_stcend
+ lda tmp2
+ cmp sectab_1541_h+1,x
+ bne _nxt
+ lda tmp1
+ cmp sectab_1541_l+1,x
+ bcc _found
+_nxt: inx
+ cpx #35
+ bne _loop41
+ beq _inv_data
+
+_found:
+ lda tmp1
+ sec
+ sbc sectab_1541_l,x
+ sta tmp2
+_fndend:
+ inx
+ stx tmp1
+ jmp dio_stcend
dio_stc1571:
; if 1571:
; - check size, if too big - subtract and add 35 to track
; - fall down to 1541
- lda tmp2
- cmp #>683
- bne _cnt71
- lda tmp1
- cmp #<683
- bcc dio_stc1541
-
-_cnt71:
- lda tmp1
- sec
- sbc #<683
- sta tmp1
- lda tmp2
- sbc #>683
- sta tmp2
- jsr dio_stc1541 ; will fall through here
-
- ldy #diopp_track
- lda (ptr1),y
- clc
- adc #35
- sta (ptr1),y
- lda #0
- beq _ret
+ lda tmp2
+ cmp #>683
+ bne _cnt71
+ lda tmp1
+ cmp #<683
+ bcc dio_stc1541
+
+_cnt71:
+ lda tmp1
+ sec
+ sbc #<683
+ sta tmp1
+ lda tmp2
+ sbc #>683
+ sta tmp2
+ jsr dio_stc1541 ; will fall through here
+
+ ldy #diopp_track
+ lda (ptr1),y
+ clc
+ adc #35
+ sta (ptr1),y
+ lda #0
+ beq _ret
; if 1581:
; - subtract 40 in loop (at most 80 times) to find track
; - the remainder is sector
dio_stc1581:
- ldx #0 ; index=(track-1)
-_loop81:
- lda tmp2
- bne _sub81
- lda tmp1
- cmp #40
- bcc _got81
-_sub81: lda tmp1
- sec
- sbc #40
- sta tmp1
- lda tmp2
- sbc #0
- sta tmp2
- inx
- cpx #81
- bne _loop81
- beq _inv_data
-
-_got81: lda tmp1
- sta tmp2
- inx
- stx tmp1
- jmp dio_stcend
-
-.endproc
+ ldx #0 ; index=(track-1)
+_loop81:
+ lda tmp2
+ bne _sub81
+ lda tmp1
+ cmp #40
+ bcc _got81
+_sub81: lda tmp1
+ sec
+ sbc #40
+ sta tmp1
+ lda tmp2
+ sbc #0
+ sta tmp2
+ inx
+ cpx #81
+ bne _loop81
+ beq _inv_data
+
+_got81: lda tmp1
+ sta tmp2
+ inx
+ stx tmp1
+ jmp dio_stcend
; sectnum_t - 16bit
;
- .import dio_params, setoserror
- .export _dio_write
- .include "geossym.inc"
- .include "jumptab.inc"
+ .import dio_params, setoserror
+ .export _dio_write
-.proc _dio_write
+ .include "geossym.inc"
+ .include "jumptab.inc"
+_dio_write:
jsr dio_params
jsr WriteBlock
jmp setoserror
-
-.endproc
; sectnum_t - 16bit
;
- .import dio_params, __oserror
- .export _dio_write_verify
- .include "geossym.inc"
- .include "jumptab.inc"
+ .import dio_params, __oserror
+ .export _dio_write_verify
-.proc _dio_write_verify
+ .include "geossym.inc"
+ .include "jumptab.inc"
+_dio_write_verify:
jsr dio_params
jsr VerWriteBlock
stx __oserror
txa
rts
-
-.endproc
; int __fastcall__ close (int fd);
; int __fastcall__ read (int fd, void* buf, unsigned count);
-FILEDES = 3 ; first free to use file descriptor
+FILEDES = 3 ; first free to use file descriptor
- .include "geossym.inc"
- .include "const.inc"
- .include "errno.inc"
- .include "fcntl.inc"
+ .importzp ptr1, ptr2, ptr3, tmp1
+ .import addysp, popax
+ .import __oserror
+ .import _FindFile, _ReadByte
+ .export _open, _close, _read
- .importzp ptr1, ptr2, ptr3, tmp1
- .import addysp, popax
- .import __oserror
- .import _FindFile, _ReadByte
-
- .export _open, _close, _read
-
-
-;--------------------------------------------------------------------------
-; _open
+ .include "geossym.inc"
+ .include "const.inc"
+ .include "errno.inc"
+ .include "fcntl.inc"
_open:
-
- cpy #4 ; correct # of arguments (bytes)?
- beq @parmok ; parameter count ok
- tya ; parm count < 4 shouldn't be needed to be...
- sec ; ...checked (it generates a c compiler warning)
- sbc #4
+ cpy #4 ; correct # of arguments (bytes)?
+ beq @parmok ; parameter count ok
+ tya ; parm count < 4 shouldn't be needed to be...
+ sec ; ...checked (it generates a c compiler warning)
+ sbc #4
tay
- jsr addysp ; fix stack, throw away unused parameters
+ jsr addysp ; fix stack, throw away unused parameters
; Parameters ok. Pop the flags and save them into tmp3
@parmok:
- jsr popax ; Get flags
- sta tmp1
- jsr popax ; Get name
- sta ptr1
- stx ptr1+1
-
- lda filedesc ; is there a file already open?
- bne @alreadyopen
-
- lda tmp1 ; check open mode
- and #(O_RDWR | O_CREAT)
- cmp #O_RDONLY ; only O_RDONLY is valid
- bne @badmode
-
- lda ptr1
- ldx ptr1+1
- jsr _FindFile ; try to find the file
+ jsr popax ; Get flags
+ sta tmp1
+ jsr popax ; Get name
+ sta ptr1
+ stx ptr1+1
+
+ lda filedesc ; is there a file already open?
+ bne @alreadyopen
+
+ lda tmp1 ; check open mode
+ and #(O_RDWR | O_CREAT)
+ cmp #O_RDONLY ; only O_RDONLY is valid
+ bne @badmode
+
+ lda ptr1
+ ldx ptr1+1
+ jsr _FindFile ; try to find the file
tax
- bne @oserror
-
- lda dirEntryBuf + OFF_DE_TR_SC ; tr&se for ReadByte (r1)
- sta f_track
- lda dirEntryBuf + OFF_DE_TR_SC + 1
- sta f_sector
- lda #<diskBlkBuf ; buffer for ReadByte (r4)
- sta f_buffer
- lda #>diskBlkBuf
- sta f_buffer+1
- ldx #0 ; offset for ReadByte (r5)
- stx f_offset
- stx f_offset+1
- lda #0 ; clear errors
- sta __oserror
- jsr __seterrno
- lda #FILEDES ; return fd
- sta filedesc
+ bne @oserror
+
+ lda dirEntryBuf + OFF_DE_TR_SC ; tr&se for ReadByte (r1)
+ sta f_track
+ lda dirEntryBuf + OFF_DE_TR_SC + 1
+ sta f_sector
+ lda #<diskBlkBuf ; buffer for ReadByte (r4)
+ sta f_buffer
+ lda #>diskBlkBuf
+ sta f_buffer+1
+ ldx #0 ; offset for ReadByte (r5)
+ stx f_offset
+ stx f_offset+1
+ lda #0 ; clear errors
+ sta __oserror
+ jsr __seterrno
+ lda #FILEDES ; return fd
+ sta filedesc
rts
@badmode:
- lda #EINVAL ; invalid parameters - invalid open mode
- .byte $2c ; skip
+ lda #EINVAL ; invalid parameters - invalid open mode
+ .byte $2c ; skip
@alreadyopen:
- lda #EMFILE ; too many opened files (there can be only one)
- jmp __directerrno ; set errno, clear oserror, return -1
+ lda #EMFILE ; too many opened files (there can be only one)
+ jmp __directerrno ; set errno, clear oserror, return -1
@oserror:
- jmp __mappederrno ; set platform error code, return -1
+ jmp __mappederrno ; set platform error code, return -1
_close:
- lda #0
- sta __oserror
- jsr __seterrno ; clear errors
- lda #0 ; clear fd
- sta filedesc
+ lda #0
+ sta __oserror
+ jsr __seterrno ; clear errors
+ lda #0 ; clear fd
+ sta filedesc
tax
rts
; popax - fd, must be == to the above one
; return -1+__oserror or number of bytes read
- eor #$ff
- sta ptr1
+ eor #$ff
+ sta ptr1
txa
- eor #$ff
- sta ptr1+1 ; -(# of bytes to read)-1
- jsr popax
- sta ptr2
- stx ptr2+1 ; buffer ptr
- jsr popax
- cmp #FILEDES ; lo-byte == FILEDES
- bne @filenotopen
+ eor #$ff
+ sta ptr1+1 ; -(# of bytes to read)-1
+ jsr popax
+ sta ptr2
+ stx ptr2+1 ; buffer ptr
+ jsr popax
+ cmp #FILEDES ; lo-byte == FILEDES
+ bne @filenotopen
txa ; hi-byte == 0
- beq @fileok ; fd must be == FILEDES
+ beq @fileok ; fd must be == FILEDES
@filenotopen:
- lda #EBADF
- jmp __directerrno ; Sets _errno, clears _oserror, returns -1
+ lda #EBADF
+ jmp __directerrno ; Sets _errno, clears _oserror, returns -1
@fileok:
- lda #0
- sta ptr3
- sta ptr3+1 ; put 0 into ptr3 (number of bytes read)
- sta __oserror ; clear error flags
- jsr __seterrno
-
- lda f_track ; restore stuff for ReadByte
- ldx f_sector
- sta r1L
- stx r1H
- lda f_buffer
- ldx f_buffer+1
- sta r4L
- stx r4H
- lda f_offset
- ldx f_offset+1
- sta r5L
- stx r5H
+ lda #0
+ sta ptr3
+ sta ptr3+1 ; put 0 into ptr3 (number of bytes read)
+ sta __oserror ; clear error flags
+ jsr __seterrno
+
+ lda f_track ; restore stuff for ReadByte
+ ldx f_sector
+ sta r1L
+ stx r1H
+ lda f_buffer
+ ldx f_buffer+1
+ sta r4L
+ stx r4H
+ lda f_offset
+ ldx f_offset+1
+ sta r5L
+ stx r5H
clc
- bcc @L3 ; branch always
-
-@L0: jsr _ReadByte
- ldy #0 ; store the byte
- sta (ptr2),y
- inc ptr2 ; increment target address
- bne @L1
- inc ptr2+1
-
-@L1: inc ptr3 ; increment byte count
- bne @L2
- inc ptr3+1
-
-@L2: lda __oserror ; was there error ?
- beq @L3
- cmp #BFR_OVERFLOW ; EOF?
- beq @done ; yes, we're done
- jmp __mappederrno ; no, we're screwed
-
-@L3: inc ptr1 ; decrement the count
- bne @L0
- inc ptr1+1
- bne @L0
+ bcc @L3 ; branch always
+
+@L0: jsr _ReadByte
+ ldy #0 ; store the byte
+ sta (ptr2),y
+ inc ptr2 ; increment target address
+ bne @L1
+ inc ptr2+1
+
+@L1: inc ptr3 ; increment byte count
+ bne @L2
+ inc ptr3+1
+
+@L2: lda __oserror ; was there error ?
+ beq @L3
+ cmp #BFR_OVERFLOW ; EOF?
+ beq @done ; yes, we're done
+ jmp __mappederrno ; no, we're screwed
+
+@L3: inc ptr1 ; decrement the count
+ bne @L0
+ inc ptr1+1
+ bne @L0
@done:
- lda r1L ; preserve data for ReadByte
- ldx r1H
- sta f_track
- stx f_sector
- lda r4L
- ldx r4H
- sta f_buffer
- stx f_buffer+1
- lda r5L
- ldx r5H
- sta f_offset
- stx f_offset+1
-
- lda ptr3 ; return byte count
- ldx ptr3+1
+ lda r1L ; preserve data for ReadByte
+ ldx r1H
+ sta f_track
+ stx f_sector
+ lda r4L
+ ldx r4H
+ sta f_buffer
+ stx f_buffer+1
+ lda r5L
+ ldx r5H
+ sta f_offset
+ stx f_offset+1
+
+ lda ptr3 ; return byte count
+ ldx ptr3+1
rts
.bss
-filedesc: .res 1 ; file open flag - 0 (no file opened) or 1
-f_track: .res 1 ; values preserved for ReadByte
-f_sector: .res 1
-f_offset: .res 2
-f_buffer: .res 2
+
+filedesc:
+ .res 1 ; file open flag - 0 (no file opened) or 1
+f_track:
+ .res 1 ; values preserved for ReadByte
+f_sector:
+ .res 1
+f_offset:
+ .res 2
+f_buffer:
+ .res 2
; Ullrich von Bassewitz, 2002-12-20
;
- .include "zeropage.inc"
-
- .include "joy-kernel.inc"
- .include "joy-error.inc"
- .include "geossym.inc"
-
- .macpack generic
+ .include "zeropage.inc"
+ .include "joy-kernel.inc"
+ .include "joy-error.inc"
+ .include "geossym.inc"
+ .macpack generic
; ------------------------------------------------------------------------
; Header. Includes jump table
-.segment "JUMPTABLE"
+.segment "JUMPTABLE"
; Driver signature
- .byte $6A, $6F, $79 ; "joy"
- .byte JOY_API_VERSION ; Driver API version number
+ .byte $6A, $6F, $79 ; "joy"
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
- .byte $01 ; JOY_UP
- .byte $02 ; JOY_DOWN
- .byte $04 ; JOY_LEFT
- .byte $08 ; JOY_RIGHT
- .byte $10 ; JOY_FIRE
- .byte $00 ; Future expansion
- .byte $00 ; Future expansion
- .byte $00 ; Future expansion
+ .byte $01 ; JOY_UP
+ .byte $02 ; JOY_DOWN
+ .byte $04 ; JOY_LEFT
+ .byte $08 ; JOY_RIGHT
+ .byte $10 ; JOY_FIRE
+ .byte $00 ; Future expansion
+ .byte $00 ; Future expansion
+ .byte $00 ; Future expansion
; Jump table.
- .word INSTALL
- .word UNINSTALL
- .word COUNT
- .word READ
+ .word INSTALL
+ .word UNINSTALL
+ .word COUNT
+ .word READ
; ------------------------------------------------------------------------
; Constants
-JOY_COUNT = 2 ; Number of joysticks we support
-
+JOY_COUNT = 2 ; Number of joysticks we support
; ------------------------------------------------------------------------
; Data.
-
.code
; ------------------------------------------------------------------------
;
INSTALL:
- lda #<JOY_ERR_OK
- ldx #>JOY_ERR_OK
-; rts ; Run into UNINSTALL instead
+ lda #<JOY_ERR_OK
+ ldx #>JOY_ERR_OK
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
;
UNINSTALL:
- rts
+ rts
; ------------------------------------------------------------------------
;
COUNT:
- lda #<JOY_COUNT
- ldx #>JOY_COUNT
- rts
+ lda #<JOY_COUNT
+ ldx #>JOY_COUNT
+ rts
; ------------------------------------------------------------------------
; READ: Read a particular joystick passed in A.
READ:
tax
php
- sei ; disable IRQ
- lda $01
+ sei ; disable IRQ
+ lda $01
pha
- lda #$35
- sta $01 ; enable I/O
+ lda #$35
+ sta $01 ; enable I/O
- txa ; Joystick number into X
- bne joy2
+ txa ; Joystick number into X
+ bne joy2
; Read joystick 1
joy1:
- lda #$7F
- sta cia1base
- lda cia1base+1
+ lda #$7F
+ sta cia1base
+ lda cia1base+1
back: tay
pla
- sta $01
+ sta $01
plp
tya
- and #$1F
- eor #$1F
- rts
+ and #$1F
+ eor #$1F
+ rts
; Read joystick 2
-joy2: ldx #0
- lda #$E0
- ldy #$FF
- sta cia1base+2
- lda cia1base+1
- sty cia1base+2
- jmp back
+joy2: ldx #0
+ lda #$E0
+ ldy #$FF
+ sta cia1base+2
+ lda cia1base+1
+ sty cia1base+2
+ jmp back
; 2010-08-17, Maciej 'YTM/Elysium' Witkowiak <ytm@elysium.pl>
; 2010-08-18, Greg King
- .include "zeropage.inc"
-
- .include "tgi-kernel.inc"
- .include "tgi-error.inc"
-
- .include "const.inc"
- .include "jumptab.inc"
- .include "geossym.inc"
- .include "geossym2.inc"
-
- .macpack generic
+ .include "zeropage.inc"
+ .include "tgi-kernel.inc"
+ .include "tgi-error.inc"
+ .include "const.inc"
+ .include "jumptab.inc"
+ .include "geossym.inc"
+ .include "geossym2.inc"
+
+ .macpack generic
; ------------------------------------------------------------------------
; Constants
-VDC_ADDR_REG := $D600 ; VDC address
-VDC_DATA_REG := $D601 ; VDC data
+VDC_ADDR_REG := $D600 ; VDC address
+VDC_DATA_REG := $D601 ; VDC data
-VDC_DSP_HI = 12 ; registers used
-VDC_DSP_LO = 13
-VDC_DATA_HI = 18
-VDC_DATA_LO = 19
-VDC_VSCROLL = 24
-VDC_HSCROLL = 25
-VDC_COLORS = 26
-VDC_CSET = 28
-VDC_COUNT = 30
-VDC_DATA = 31
+VDC_DSP_HI = 12 ; registers used
+VDC_DSP_LO = 13
+VDC_DATA_HI = 18
+VDC_DATA_LO = 19
+VDC_VSCROLL = 24
+VDC_HSCROLL = 25
+VDC_COLORS = 26
+VDC_CSET = 28
+VDC_COUNT = 30
+VDC_DATA = 31
; ------------------------------------------------------------------------
; Header. Includes jump table and constants.
-.segment "JUMPTABLE"
+.segment "JUMPTABLE"
; First part of the header is a structure that has a magic signature,
; and defines the capabilities of the driver.
- .byte $74, $67, $69 ; "tgi"
- .byte TGI_API_VERSION ; TGI API version number
-xres: .word 320 ; X resolution
-yres: .word 200 ; Y resolution
- .byte 2 ; Number of drawing colors
-pages: .byte 1 ; Number of screens available
- .byte 8 ; System font X size
- .byte 8 ; System font Y size
-aspect: .word $00D4 ; Aspect ratio (based on 4/3 display)
- .byte 0 ; TGI driver flags
+ .byte $74, $67, $69 ; "tgi"
+ .byte TGI_API_VERSION ; TGI API version number
+xres: .word 320 ; X resolution
+yres: .word 200 ; Y resolution
+ .byte 2 ; Number of drawing colors
+pages: .byte 1 ; Number of screens available
+ .byte 8 ; System font X size
+ .byte 8 ; System font Y size
+aspect: .word $00D4 ; Aspect ratio (based on 4/3 display)
+ .byte 0 ; TGI driver flags
; Next comes the jump table. With the exception of IRQ, all entries must be
; valid, and may point to an RTS for test versions (function not implemented).
- .addr INSTALL
- .addr UNINSTALL
- .addr INIT
- .addr DONE
- .addr GETERROR
- .addr CONTROL
- .addr CLEAR
- .addr SETVIEWPAGE
- .addr SETDRAWPAGE
- .addr SETCOLOR
- .addr SETPALETTE
- .addr GETPALETTE
- .addr GETDEFPALETTE
- .addr SETPIXEL
- .addr GETPIXEL
- .addr LINE
- .addr BAR
- .addr TEXTSTYLE
- .addr OUTTEXT
- .addr 0 ; IRQ entry is unused
+ .addr INSTALL
+ .addr UNINSTALL
+ .addr INIT
+ .addr DONE
+ .addr GETERROR
+ .addr CONTROL
+ .addr CLEAR
+ .addr SETVIEWPAGE
+ .addr SETDRAWPAGE
+ .addr SETCOLOR
+ .addr SETPALETTE
+ .addr GETPALETTE
+ .addr GETDEFPALETTE
+ .addr SETPIXEL
+ .addr GETPIXEL
+ .addr LINE
+ .addr BAR
+ .addr TEXTSTYLE
+ .addr OUTTEXT
+ .addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
; Data.
; Variables mapped to the zero-page segment variables. Some of these are
; used for passing parameters to the driver.
-X1 = ptr1
-Y1 = ptr2
-X2 = ptr3
-Y2 = ptr4
+X1 = ptr1
+Y1 = ptr2
+X2 = ptr3
+Y2 = ptr4
; Absolute variables used in the code
.bss
-SCRBASE: .res 1 ; High byte of screen base (64k VDC only)
+SCRBASE:
+ .res 1 ; High byte of screen base (64k VDC only)
-ERROR: .res 1 ; Error code
-PALETTE: .res 2 ; The current palette
+ERROR:
+ .res 1 ; Error code
+PALETTE:
+ .res 2 ; The current palette
-BITMASK: .res 1 ; $00 = clear, $01 = set pixels
+BITMASK:
+ .res 1 ; $00 = clear, $01 = set pixels
-OLDCOLOR: .res 1 ; colors before entering gfx mode
+OLDCOLOR:
+ .res 1 ; colors before entering gfx mode
; Text output stuff
-TEXTMAGX: .res 1
-TEXTMAGY: .res 1
-TEXTDIR: .res 1
+TEXTMAGX:
+ .res 1
+TEXTMAGY:
+ .res 1
+TEXTDIR:
+ .res 1
; Constants and tables
.rodata
-DEFPALETTE: .byte $00, $0f ; White on black
+DEFPALETTE:
+ .byte $00, $0f ; White on black
PALETTESIZE = * - DEFPALETTE
; color translation table (indexed by VIC color)
-COLTRANS: .byte $00, $0f, $08, $06, $0a, $04, $02, $0c
- .byte $0d, $0b, $09, $01, $0e, $05, $03, $07
- ; colors BROWN and GRAY3 are wrong
+COLTRANS:
+ .byte $00, $0f, $08, $06, $0a, $04, $02, $0c
+ .byte $0d, $0b, $09, $01, $0e, $05, $03, $07
+ ; colors BROWN and GRAY3 are wrong
.code
beq @L40
lda c128Flag ; at least GEOS 2.0, but we're on C128?
bpl @L40
- lda graphMode ; GEOS 2.0, C128, but is 80 column screen enabled?
- bmi @L80
+ lda graphMode ; GEOS 2.0, C128, but is 80 column screen enabled?
+ bmi @L80
@L40: rts ; leave default values for 40 column screen
; check for VDC version and update register $19 value
@L80:
; double the x resolution and halve the aspect ratio
- asl xres
- rol xres+1
+ asl xres
+ rol xres+1
- lsr aspect+1
- ror aspect
+ lsr aspect+1
+ ror aspect
; update number of available screens
- ldx #VDC_CSET ; determine size of RAM...
- jsr VDCReadReg
- sta tmp1
- ora #%00010000
- jsr VDCWriteReg ; turn on 64k
-
- jsr settestadr1 ; save original value of test byte
- jsr VDCReadByte
- sta tmp2
-
- lda #$55 ; write $55 here
- ldy #ptr1
- jsr test64k ; read it here and there
- lda #$aa ; write $aa here
- ldy #ptr2
- jsr test64k ; read it here and there
-
- jsr settestadr1
- lda tmp2
- jsr VDCWriteByte ; restore original value of test byte
-
- lda ptr1 ; do bytes match?
- cmp ptr1+1
- bne @have64k
- lda ptr2
- cmp ptr2+1
- bne @have64k
-
- ldx #VDC_CSET
- lda tmp1
- jsr VDCWriteReg ; restore 16/64k flag
- jmp @endok ; and leave default values for 16k
+ ldx #VDC_CSET ; determine size of RAM...
+ jsr VDCReadReg
+ sta tmp1
+ ora #%00010000
+ jsr VDCWriteReg ; turn on 64k
+
+ jsr settestadr1 ; save original value of test byte
+ jsr VDCReadByte
+ sta tmp2
+
+ lda #$55 ; write $55 here
+ ldy #ptr1
+ jsr test64k ; read it here and there
+ lda #$aa ; write $aa here
+ ldy #ptr2
+ jsr test64k ; read it here and there
+
+ jsr settestadr1
+ lda tmp2
+ jsr VDCWriteByte ; restore original value of test byte
+
+ lda ptr1 ; do bytes match?
+ cmp ptr1+1
+ bne @have64k
+ lda ptr2
+ cmp ptr2+1
+ bne @have64k
+
+ ldx #VDC_CSET
+ lda tmp1
+ jsr VDCWriteReg ; restore 16/64k flag
+ jmp @endok ; and leave default values for 16k
@have64k:
- lda #4
- sta pages
+ lda #4
+ sta pages
@endok:
- lda #0
- sta SCRBASE ; draw page 0 as default
- rts
-
-test64k:
- sta tmp1
- sty ptr3
- lda #0
- sta ptr3+1
- jsr settestadr1
- lda tmp1
- jsr VDCWriteByte ; write $55
- jsr settestadr1
- jsr VDCReadByte ; read here
+ lda #0
+ sta SCRBASE ; draw page 0 as default
+ rts
+
+test64k:
+ sta tmp1
+ sty ptr3
+ lda #0
+ sta ptr3+1
+ jsr settestadr1
+ lda tmp1
+ jsr VDCWriteByte ; write $55
+ jsr settestadr1
+ jsr VDCReadByte ; read here
pha
- jsr settestadr2
- jsr VDCReadByte ; and there
- ldy #1
- sta (ptr3),y
+ jsr settestadr2
+ jsr VDCReadByte ; and there
+ ldy #1
+ sta (ptr3),y
pla
dey
- sta (ptr3),y
+ sta (ptr3),y
rts
settestadr1:
- ldy #$02 ; test page 2 (here)
- .byte $2c
+ ldy #$02 ; test page 2 (here)
+ .byte $2c
settestadr2:
- ldy #$42 ; or page 64+2 (there)
- lda #0
- jmp VDCSetSourceAddr
+ ldy #$42 ; or page 64+2 (there)
+ lda #0
+ jmp VDCSetSourceAddr
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory. May
;
UNINSTALL:
- rts
+ rts
; ------------------------------------------------------------------------
lda #ST_WR_FORE ; write only on foreground
sta dispBufferOn
- lda graphMode
- bmi @L80
+ lda graphMode
+ bmi @L80
; Remember current color value (40 columns)
lda screencolors
; Done, reset the error code
- lda #TGI_ERR_OK
- sta ERROR
- rts
+ lda #TGI_ERR_OK
+ sta ERROR
+ rts
; ------------------------------------------------------------------------
; DONE: Will be called to switch the graphics device back into text mode.
; GETERROR: Return the error code in A and clear it.
GETERROR:
- ldx #TGI_ERR_OK
- lda ERROR
- stx ERROR
- rts
+ ldx #TGI_ERR_OK
+ lda ERROR
+ stx ERROR
+ rts
; ------------------------------------------------------------------------
; CONTROL: Platform/driver specific entry point.
;
CONTROL:
- lda #TGI_ERR_INV_FUNC
- sta ERROR
- rts
+ lda #TGI_ERR_INV_FUNC
+ sta ERROR
+ rts
; ------------------------------------------------------------------------
; CLEAR: Clears the screen.
;
CLEAR:
- lda curPattern
- pha
- lda #0
- jsr SetPattern
- ldx #0
- stx r3L
- stx r3H
- stx r2L
- lda #199
- sta r2H
- lda graphMode
- bpl @L40
- lda #>639 ; 80 columns
- ldx #<639
- bne @L99
-@L40: lda #>319 ; 40 columns
- ldx #<319
-@L99: sta r4H
- stx r4L
- jsr Rectangle
- pla
- sta curPattern
- rts
+ lda curPattern
+ pha
+ lda #0
+ jsr SetPattern
+ ldx #0
+ stx r3L
+ stx r3H
+ stx r2L
+ lda #199
+ sta r2H
+ lda graphMode
+ bpl @L40
+ lda #>639 ; 80 columns
+ ldx #<639
+ bne @L99
+@L40: lda #>319 ; 40 columns
+ ldx #<319
+@L99: sta r4H
+ stx r4L
+ jsr Rectangle
+ pla
+ sta curPattern
+ rts
; ------------------------------------------------------------------------
; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
ror
ror
ror
- ldx #VDC_DSP_HI
- jmp VDCWriteReg
+ ldx #VDC_DSP_HI
+ jmp VDCWriteReg
; ------------------------------------------------------------------------
; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
ror
ror
ror
- sta SCRBASE
+ sta SCRBASE
rts
; ------------------------------------------------------------------------
;
SETCOLOR:
- tax
- beq @L1
- lda #1
-@L1: sta BITMASK
- jmp SetPattern ; need to have either 0 or 1
+ tax
+ beq @L1
+ lda #1
+@L1: sta BITMASK
+ jmp SetPattern ; need to have either 0 or 1
; ------------------------------------------------------------------------
; SETPALETTE: Set the palette (not available with all drivers/hardware).
;
SETPALETTE:
- jsr GETERROR ; clear error (if any)
+ jsr GETERROR ; clear error (if any)
- ldy #PALETTESIZE - 1
-@L1: lda (ptr1),y ; Copy the palette
- and #$0F ; Make a valid color
- sta PALETTE,y
- dey
- bpl @L1
+ ldy #PALETTESIZE - 1
+@L1: lda (ptr1),y ; Copy the palette
+ and #$0F ; Make a valid color
+ sta PALETTE,y
+ dey
+ bpl @L1
; Put colors from palette into screen
- lda graphMode
- bmi @L80
-
- lda PALETTE+1 ; foreground
- asl a
- asl a
- asl a
- asl a
- ora PALETTE ; background
- ldx #0
-@L2: sta COLOR_MATRIX,x
- sta COLOR_MATRIX+$0100,x
- sta COLOR_MATRIX+$0200,x
- sta COLOR_MATRIX+1000-256,x
+ lda graphMode
+ bmi @L80
+
+ lda PALETTE+1 ; foreground
+ asl a
+ asl a
+ asl a
+ asl a
+ ora PALETTE ; background
+ ldx #0
+@L2: sta COLOR_MATRIX,x
+ sta COLOR_MATRIX+$0100,x
+ sta COLOR_MATRIX+$0200,x
+ sta COLOR_MATRIX+1000-256,x
inx
- bne @L2
+ bne @L2
rts
-@L80: ldy PALETTE+1 ; Foreground color
- lda COLTRANS,y
- asl a
- asl a
- asl a
- asl a
- ldy PALETTE ; Background color
- ora COLTRANS,y
+@L80: ldy PALETTE+1 ; Foreground color
+ lda COLTRANS,y
+ asl a
+ asl a
+ asl a
+ asl a
+ ldy PALETTE ; Background color
+ ora COLTRANS,y
- ldx #VDC_COLORS
- jmp VDCWriteReg
+ ldx #VDC_COLORS
+ jmp VDCWriteReg
; ------------------------------------------------------------------------
; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
;
GETPALETTE:
- lda #<PALETTE
- ldx #>PALETTE
- rts
+ lda #<PALETTE
+ ldx #>PALETTE
+ rts
; ------------------------------------------------------------------------
; GETDEFPALETTE: Return the default palette for the driver in A/X. All
;
GETDEFPALETTE:
- lda #<DEFPALETTE
- ldx #>DEFPALETTE
- rts
+ lda #<DEFPALETTE
+ ldx #>DEFPALETTE
+ rts
; ------------------------------------------------------------------------
; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
;
SETPIXEL:
- lda X1
- ldx X1+1
- ldy Y1
- sta r3L
- stx r3H
- sty r11L
+ lda X1
+ ldx X1+1
+ ldy Y1
+ sta r3L
+ stx r3H
+ sty r11L
sec
- lda BITMASK ; set or clear C flag
- bne @L1
+ lda BITMASK ; set or clear C flag
+ bne @L1
clc
-@L1: lda #0
- jmp DrawPoint
+@L1: lda #0
+ jmp DrawPoint
; ------------------------------------------------------------------------
; GETPIXEL: Read the color value of a pixel and return it in A/X. The
GETPIXEL:
- lda X1
- ldx X1+1
- ldy Y1
- sta r3L
- stx r3H
- sty r11L
- jsr TestPoint
- ldx #0
- bcc @L1
+ lda X1
+ ldx X1+1
+ ldy Y1
+ sta r3L
+ stx r3H
+ sty r11L
+ jsr TestPoint
+ ldx #0
+ bcc @L1
inx
@L1: txa
- ldx #0
+ ldx #0
rts
; ------------------------------------------------------------------------
;
LINE:
- lda X1
- ldx X1+1
- ldy Y1
- sta r3L
- stx r3H
- sty r11L
- lda X2
- ldx X2+1
- ldy Y2
- sta r4L
- stx r4H
- sty r11H
+ lda X1
+ ldx X1+1
+ ldy Y1
+ sta r3L
+ stx r3H
+ sty r11L
+ lda X2
+ ldx X2+1
+ ldy Y2
+ sta r4L
+ stx r4H
+ sty r11H
sec
- lda BITMASK ; set or clear C flag
- bne @L1
+ lda BITMASK ; set or clear C flag
+ bne @L1
clc
-@L1: lda #0
- jmp DrawLine
+@L1: lda #0
+ jmp DrawLine
; ------------------------------------------------------------------------
; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
;
BAR:
- lda X1
- ldx X1+1
- ldy Y1
- sta r3L
- stx r3H
- sty r2L
- lda X2
- ldx X2+1
- ldy Y2
- sta r4L
- stx r4H
- sty r2H
- jmp Rectangle
+ lda X1
+ ldx X1+1
+ ldy Y1
+ sta r3L
+ stx r3H
+ sty r2L
+ lda X2
+ ldx X2+1
+ ldy Y2
+ sta r4L
+ stx r4H
+ sty r2H
+ jmp Rectangle
; ------------------------------------------------------------------------
; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y
;
TEXTSTYLE:
- stx TEXTMAGX
- sty TEXTMAGY
- sta TEXTDIR
- rts
+ stx TEXTMAGX
+ sty TEXTMAGY
+ sta TEXTDIR
+ rts
; ------------------------------------------------------------------------
;
OUTTEXT:
- lda TEXTDIR
-; cmp #TGI_TEXT_HORIZONTAL ; this is equal 0
- bne @vertical
-
- lda X1 ; horizontal text output
- ldx X1+1
- ldy Y1
- sta r11L
- stx r11H
- sty r1H
- lda ptr3
- ldx ptr3+1
- sta r0L
- stx r0H
- jmp PutString
+ lda TEXTDIR
+; cmp #TGI_TEXT_HORIZONTAL ; this is equal 0
+ bne @vertical
+
+ lda X1 ; horizontal text output
+ ldx X1+1
+ ldy Y1
+ sta r11L
+ stx r11H
+ sty r1H
+ lda ptr3
+ ldx ptr3+1
+ sta r0L
+ stx r0H
+ jmp PutString
@vertical:
- lda X1 ; vertical text output
- ldx X1+1
- ldy Y1
- sta r11L
- stx r11H
- sty r1H
- ldy #0
- lda (ptr3),y
- beq @end
- jsr PutChar
- inc ptr3
- bne @L1
- inc ptr3+1
-@L1: lda Y1
+ lda X1 ; vertical text output
+ ldx X1+1
+ ldy Y1
+ sta r11L
+ stx r11H
+ sty r1H
+ ldy #0
+ lda (ptr3),y
+ beq @end
+ jsr PutChar
+ inc ptr3
+ bne @L1
+ inc ptr3+1
+@L1: lda Y1
clc
- adc #8
- sta Y1
- bne @vertical
+ adc #8
+ sta Y1
+ bne @vertical
@end: rts
;-------------
VDCSetSourceAddr:
pha
tya
- ldx #VDC_DATA_HI
- jsr VDCWriteReg
+ ldx #VDC_DATA_HI
+ jsr VDCWriteReg
pla
- ldx #VDC_DATA_LO
- bne VDCWriteReg
+ ldx #VDC_DATA_LO
+ bne VDCWriteReg
VDCReadByte:
- ldx #VDC_DATA
+ ldx #VDC_DATA
VDCReadReg:
- stx VDC_ADDR_REG
-@L0: bit VDC_ADDR_REG
- bpl @L0
- lda VDC_DATA_REG
+ stx VDC_ADDR_REG
+@L0: bit VDC_ADDR_REG
+ bpl @L0
+ lda VDC_DATA_REG
rts
VDCWriteByte:
- ldx #VDC_DATA
+ ldx #VDC_DATA
VDCWriteReg:
- stx VDC_ADDR_REG
-@L0: bit VDC_ADDR_REG
- bpl @L0
- sta VDC_DATA_REG
+ stx VDC_ADDR_REG
+@L0: bit VDC_ADDR_REG
+ bpl @L0
+ sta VDC_DATA_REG
rts
-
; Maciej 'YTM/Elysium' Witkowiak <ytm@elysium.pl>
; 06,20,25.12.2002
- .include "zeropage.inc"
-
- .include "em-kernel.inc"
- .include "em-error.inc"
-
-
- .macpack generic
+ .include "zeropage.inc"
+ .include "em-kernel.inc"
+ .include "em-error.inc"
+ .macpack generic
; ------------------------------------------------------------------------
; Header. Includes jump table
-.segment "JUMPTABLE"
+.segment "JUMPTABLE"
; Driver signature
- .byte $65, $6d, $64 ; "emd"
- .byte EMD_API_VERSION ; EM API version number
+ .byte $65, $6d, $64 ; "emd"
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
- .word INSTALL
- .word UNINSTALL
- .word PAGECOUNT
- .word MAP
- .word USE
- .word COMMIT
- .word COPYFROM
- .word COPYTO
+ .word INSTALL
+ .word UNINSTALL
+ .word PAGECOUNT
+ .word MAP
+ .word USE
+ .word COMMIT
+ .word COPYFROM
+ .word COPYTO
; ------------------------------------------------------------------------
; Constants
-VDC_ADDR_REG = $D600 ; VDC address
-VDC_DATA_REG = $D601 ; VDC data
+VDC_ADDR_REG = $D600 ; VDC address
+VDC_DATA_REG = $D601 ; VDC data
-VDC_DATA_HI = 18 ; used registers
-VDC_DATA_LO = 19
-VDC_CSET = 28
-VDC_DATA = 31
+VDC_DATA_HI = 18 ; used registers
+VDC_DATA_LO = 19
+VDC_CSET = 28
+VDC_DATA = 31
; ------------------------------------------------------------------------
; Data.
.data
-pagecount: .word 64 ; $0000-$3fff as 16k default
-curpage: .word $ffff ; currently mapped-in page (invalid)
+pagecount:
+ .word 64 ; $0000-$3fff as 16k default
+curpage:
+ .word $ffff ; currently mapped-in page (invalid)
.bss
-window: .res 256 ; memory window
+window: .res 256 ; memory window
.code
php
sei
- lda $01
+ lda $01
pha
- lda #$35
- sta $01
-
- ldx #VDC_CSET ; determine size of RAM...
- jsr vdcgetreg
- sta tmp1
- ora #%00010000
- jsr vdcputreg ; turn on 64k
-
- jsr settestadr1 ; save original value of test byte
- jsr vdcgetbyte
- sta tmp2
-
- lda #$55 ; write $55 here
- ldy #ptr1
- jsr test64k ; read it here and there
- lda #$aa ; write $aa here
- ldy #ptr2
- jsr test64k ; read it here and there
-
- jsr settestadr1
- lda tmp2
- jsr vdcputbyte ; restore original value of test byte
-
- lda ptr1 ; do bytes match?
- cmp ptr1+1
- bne @have64k
- lda ptr2
- cmp ptr2+1
- bne @have64k
-
- ldx #VDC_CSET
- lda tmp1
- jsr vdcputreg ; restore 16/64k flag
- jmp @endok ; and leave default values for 16k
-
-@have64k:
- lda #<256
- ldx #>256
- sta pagecount
- stx pagecount+1
-@endok:
+ lda #$35
+ sta $01
+
+ ldx #VDC_CSET ; determine size of RAM...
+ jsr vdcgetreg
+ sta tmp1
+ ora #%00010000
+ jsr vdcputreg ; turn on 64k
+
+ jsr settestadr1 ; save original value of test byte
+ jsr vdcgetbyte
+ sta tmp2
+
+ lda #$55 ; write $55 here
+ ldy #ptr1
+ jsr test64k ; read it here and there
+ lda #$aa ; write $aa here
+ ldy #ptr2
+ jsr test64k ; read it here and there
+
+ jsr settestadr1
+ lda tmp2
+ jsr vdcputbyte ; restore original value of test byte
+
+ lda ptr1 ; do bytes match?
+ cmp ptr1+1
+ bne @have64k
+ lda ptr2
+ cmp ptr2+1
+ bne @have64k
+
+ ldx #VDC_CSET
+ lda tmp1
+ jsr vdcputreg ; restore 16/64k flag
+ jmp @endok ; and leave default values for 16k
+
+@have64k:
+ lda #<256
+ ldx #>256
+ sta pagecount
+ stx pagecount+1
+@endok:
pla
- sta $01
+ sta $01
plp
- lda #<EM_ERR_OK
- ldx #>EM_ERR_OK
- rts
-
-test64k:
- sta tmp1
- sty ptr3
- lda #0
- sta ptr3+1
- jsr settestadr1
- lda tmp1
- jsr vdcputbyte ; write $55
- jsr settestadr1
- jsr vdcgetbyte ; read here
+ lda #<EM_ERR_OK
+ ldx #>EM_ERR_OK
+ rts
+
+test64k:
+ sta tmp1
+ sty ptr3
+ lda #0
+ sta ptr3+1
+ jsr settestadr1
+ lda tmp1
+ jsr vdcputbyte ; write $55
+ jsr settestadr1
+ jsr vdcgetbyte ; read here
pha
- jsr settestadr2
- jsr vdcgetbyte ; and there
- ldy #1
- sta (ptr3),y
+ jsr settestadr2
+ jsr vdcgetbyte ; and there
+ ldy #1
+ sta (ptr3),y
pla
dey
- sta (ptr3),y
+ sta (ptr3),y
rts
settestadr1:
- ldy #$02 ; test page 2 (here)
- .byte $2c
+ ldy #$02 ; test page 2 (here)
+ .byte $2c
settestadr2:
- ldy #$42 ; or page 64+2 (there)
- lda #0
- jmp vdcsetsrcaddr
+ ldy #$42 ; or page 64+2 (there)
+ lda #0
+ jmp vdcsetsrcaddr
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
;
UNINSTALL:
- ;on C128 restore font and clear the screen?
- rts
+ ;on C128 restore font and clear the screen?
+ rts
; ------------------------------------------------------------------------
; PAGECOUNT: Return the total number of available pages in a/x.
;
PAGECOUNT:
- lda pagecount
- ldx pagecount+1
- rts
+ lda pagecount
+ ldx pagecount+1
+ rts
; ------------------------------------------------------------------------
; MAP: Map the page in a/x into memory and return a pointer to the page in
; by the driver.
;
-MAP: sta curpage
- stx curpage+1
- sta ptr1+1
- ldy #0
- sty ptr1
-
- lda #<window
- sta ptr2
- lda #>window
- sta ptr2+1
-
- jsr transferin
-
- lda #<window
- ldx #>window
+MAP: sta curpage
+ stx curpage+1
+ sta ptr1+1
+ ldy #0
+ sty ptr1
+
+ lda #<window
+ sta ptr2
+ lda #>window
+ sta ptr2+1
+
+ jsr transferin
+
+ lda #<window
+ ldx #>window
rts
; copy a single page from (ptr1):VDCRAM to (ptr2):RAM
transferin:
php
sei
- lda $01
+ lda $01
pha
- lda #$35
- sta $01
- lda ptr1
- ldy ptr1+1
- jsr vdcsetsrcaddr ; set source address in VDC
- ldy #0
- ldx #VDC_DATA
- stx VDC_ADDR_REG
-@L0: bit VDC_ADDR_REG
- bpl @L0
- lda VDC_DATA_REG ; get 2 bytes at a time to speed-up
- sta (ptr2),y ; (in fact up to 8 bytes could be fetched with special VDC config)
+ lda #$35
+ sta $01
+ lda ptr1
+ ldy ptr1+1
+ jsr vdcsetsrcaddr ; set source address in VDC
+ ldy #0
+ ldx #VDC_DATA
+ stx VDC_ADDR_REG
+@L0: bit VDC_ADDR_REG
+ bpl @L0
+ lda VDC_DATA_REG ; get 2 bytes at a time to speed-up
+ sta (ptr2),y ; (in fact up to 8 bytes could be fetched with special VDC config)
iny
- lda VDC_DATA_REG
- sta (ptr2),y
+ lda VDC_DATA_REG
+ sta (ptr2),y
iny
- bne @L0
+ bne @L0
pla
- sta $01
+ sta $01
plp
rts
; ------------------------------------------------------------------------
; USE: Tell the driver that the window is now associated with a given page.
-USE: sta curpage
- stx curpage+1 ; Remember the page
- lda #<window
- ldx #>window ; Return the window
+USE: sta curpage
+ stx curpage+1 ; Remember the page
+ lda #<window
+ ldx #>window ; Return the window
done: rts
; ------------------------------------------------------------------------
; COMMIT: Commit changes in the memory window to extended storage.
COMMIT:
- lda curpage ; jump if no page mapped
- ldx curpage+1
- bmi done
- sta ptr1+1
- ldy #0
- sty ptr1
-
- lda #<window
- sta ptr2
- lda #>window
- sta ptr2+1
+ lda curpage ; jump if no page mapped
+ ldx curpage+1
+ bmi done
+ sta ptr1+1
+ ldy #0
+ sty ptr1
+
+ lda #<window
+ sta ptr2
+ lda #>window
+ sta ptr2+1
; fall through to transferout
transferout:
php
sei
- lda $01
+ lda $01
pha
- lda #$35
- sta $01
- lda ptr1
- ldy ptr1+1
- jsr vdcsetsrcaddr ; set source address in VDC
- ldy #0
- ldx #VDC_DATA
- stx VDC_ADDR_REG
-@L0: bit VDC_ADDR_REG
- bpl @L0
- lda (ptr2),y ; speedup does not work for writing
- sta VDC_DATA_REG
+ lda #$35
+ sta $01
+ lda ptr1
+ ldy ptr1+1
+ jsr vdcsetsrcaddr ; set source address in VDC
+ ldy #0
+ ldx #VDC_DATA
+ stx VDC_ADDR_REG
+@L0: bit VDC_ADDR_REG
+ bpl @L0
+ lda (ptr2),y ; speedup does not work for writing
+ sta VDC_DATA_REG
iny
- bne @L0
+ bne @L0
pla
- sta $01
+ sta $01
plp
rts
;
COPYFROM:
- jsr setup
- beq @L2 ; Skip if no full pages
+ jsr setup
+ beq @L2 ; Skip if no full pages
; Copy full pages
-@L1: jsr transferin
- inc ptr1+1
- inc ptr2+1
- dec tmp1
- bne @L1
+@L1: jsr transferin
+ inc ptr1+1
+ inc ptr2+1
+ dec tmp1
+ bne @L1
; Copy the remainder of the page
-@L2: ldy #EM_COPY::COUNT
- lda (ptr3),y ; Get bytes in last page
- beq @L4
- sta tmp1
+@L2: ldy #EM_COPY::COUNT
+ lda (ptr3),y ; Get bytes in last page
+ beq @L4
+ sta tmp1
; Transfer the bytes in the last page
php
sei
- lda $01
+ lda $01
pha
- lda #$35
- sta $01
- ldy #0
-@L3: jsr vdcgetbyte
- sta (ptr2),y
+ lda #$35
+ sta $01
+ ldy #0
+@L3: jsr vdcgetbyte
+ sta (ptr2),y
iny
- dec tmp1
- lda tmp1
- bne @L3
+ dec tmp1
+ lda tmp1
+ bne @L3
pla
- sta $01
+ sta $01
plp
@L4: rts
;
COPYTO:
- jsr setup
- beq @L2 ; Skip if no full pages
+ jsr setup
+ beq @L2 ; Skip if no full pages
; Copy full pages
-@L1: jsr transferout
- inc ptr1+1
- inc ptr2+1
- dec tmp1
- bne @L1
+@L1: jsr transferout
+ inc ptr1+1
+ inc ptr2+1
+ dec tmp1
+ bne @L1
; Copy the remainder of the page
-@L2: ldy #EM_COPY::COUNT
- lda (ptr3),y ; Get bytes in last page
- beq @L4
- sta tmp1
+@L2: ldy #EM_COPY::COUNT
+ lda (ptr3),y ; Get bytes in last page
+ beq @L4
+ sta tmp1
; Transfer the bytes in the last page
php
sei
- lda $01
+ lda $01
pha
- lda #$35
- sta $01
- ldy #0
-@L3: lda (ptr2),y
- jsr vdcputbyte
+ lda #$35
+ sta $01
+ ldy #0
+@L3: lda (ptr2),y
+ jsr vdcputbyte
iny
- dec tmp1
- lda tmp1
- bne @L3
+ dec tmp1
+ lda tmp1
+ bne @L3
pla
- sta $01
+ sta $01
plp
@L4: rts
;
vdcsetsrcaddr:
- ldx #VDC_DATA_LO
- stx VDC_ADDR_REG
-@L0: bit VDC_ADDR_REG
- bpl @L0
- sta VDC_DATA_REG
+ ldx #VDC_DATA_LO
+ stx VDC_ADDR_REG
+@L0: bit VDC_ADDR_REG
+ bpl @L0
+ sta VDC_DATA_REG
dex
tya
- stx VDC_ADDR_REG
- sta VDC_DATA_REG
+ stx VDC_ADDR_REG
+ sta VDC_DATA_REG
rts
vdcgetbyte:
- ldx #VDC_DATA
+ ldx #VDC_DATA
vdcgetreg:
- stx VDC_ADDR_REG
-@L0: bit VDC_ADDR_REG
- bpl @L0
- lda VDC_DATA_REG
- rts
-
-vdcputbyte:
- ldx #VDC_DATA
+ stx VDC_ADDR_REG
+@L0: bit VDC_ADDR_REG
+ bpl @L0
+ lda VDC_DATA_REG
+ rts
+
+vdcputbyte:
+ ldx #VDC_DATA
vdcputreg:
- stx VDC_ADDR_REG
-@L0: bit VDC_ADDR_REG
- bpl @L0
- sta VDC_DATA_REG
+ stx VDC_ADDR_REG
+@L0: bit VDC_ADDR_REG
+ bpl @L0
+ sta VDC_DATA_REG
rts
; ------------------------------------------------------------------------
;
setup:
- sta ptr3
- stx ptr3+1 ; Save the passed em_copy pointer
-
- ldy #EM_COPY::OFFS
- lda (ptr3),y
- sta ptr1
- ldy #EM_COPY::PAGE
- lda (ptr3),y
- sta ptr1+1 ; From
-
- ldy #EM_COPY::BUF
- lda (ptr3),y
- sta ptr2
- iny
- lda (ptr3),y
- sta ptr2+1 ; To
-
- ldy #EM_COPY::COUNT+1
- lda (ptr3),y ; Get number of pages
- sta tmp1
- rts
+ sta ptr3
+ stx ptr3+1 ; Save the passed em_copy pointer
+
+ ldy #EM_COPY::OFFS
+ lda (ptr3),y
+ sta ptr1
+ ldy #EM_COPY::PAGE
+ lda (ptr3),y
+ sta ptr1+1 ; From
+
+ ldy #EM_COPY::BUF
+ lda (ptr3),y
+ sta ptr2
+ iny
+ lda (ptr3),y
+ sta ptr2+1 ; To
+ ldy #EM_COPY::COUNT+1
+ lda (ptr3),y ; Get number of pages
+ sta tmp1
+ rts
; const char joy_stddrv[];
;
- .export _joy_stddrv
+ .export _joy_stddrv
.rodata
-_joy_stddrv: .asciiz "geos-stdjoy.joy"
+_joy_stddrv:
+ .asciiz "geos-stdjoy.joy"
;
; const char mouse_stddrv[];
;
- .export _mouse_stddrv
- .rodata
-_mouse_stddrv: .asciiz "geos-stdmou.mou"
+ .export _mouse_stddrv
+
+.rodata
+
+_mouse_stddrv:
+ .asciiz "geos-stdmou.mou"
; Target-specific black & white values, for use by the target-shared TGI kernel
;
- .include "tgi-kernel.inc"
+ .include "tgi-kernel.inc"
-tgi_color_black = $00
-tgi_color_white = $01
+tgi_color_black = $00
+tgi_color_white = $01
; const char tgi_stddrv[];
;
- .export _tgi_stddrv
+ .export _tgi_stddrv
.rodata
-_tgi_stddrv: .asciiz "geos-tgi.tgi"
+_tgi_stddrv:
+ .asciiz "geos-tgi.tgi"
.include "geossym.inc"
_FetchRAM:
- jsr REURegs
- jmp FetchRAM
+ jsr REURegs
+ jmp FetchRAM
.include "geossym.inc"
REURegs:
- jsr DoublePop
- jsr popax
- sta r2L
- stx r2H
- jsr popa
- sta r3L
- rts
+ jsr DoublePop
+ jsr popax
+ sta r2L
+ stx r2H
+ jsr popa
+ sta r3L
+ rts
.include "geossym.inc"
_StashRAM:
- jsr REURegs
- jmp StashRAM
+ jsr REURegs
+ jmp StashRAM
.include "geossym.inc"
_SwapRAM:
- jsr REURegs
- jmp SwapRAM
+ jsr REURegs
+ jmp SwapRAM
.include "geossym.inc"
_VerifyRAM:
- jsr REURegs
- jsr VerifyRAM
- txa
- ldx #0
- rts
+ jsr REURegs
+ jsr VerifyRAM
+ txa
+ ldx #0
+ rts
; char (example: for ASCII, this must be $E0).
- .export __cdiff
+ .export __cdiff
__cdiff:
.byte $e0
; The table is taken from Craig S. Bruce technical docs for the ACE os
- .export __ctype
+ .export __ctype
__ctype:
- .byte $10 ; 0/00 ___rvs_@___
+ .byte $10 ; 0/00 ___rvs_@___
.byte $10 ; 1/01 ___rvs_a___
- .byte $10 ; 2/02 ___rvs_b___
+ .byte $10 ; 2/02 ___rvs_b___
.byte $10 ; 3/03 ___rvs_c___
.byte $10 ; 4/04 ___rvs_d___
.byte $10 ; 5/05 ___rvs_e___
.byte $10 ; 6/06 ___rvs_f___
.byte $10 ; 7/07 _BEL/rvs_g_
.byte $10 ; 8/08 ___rvs_h___
- .byte $D0 ; 9/09 _TAB/rvs_i_
+ .byte $D0 ; 9/09 _TAB/rvs_i_
.byte $50 ; 10/0a _BOL/rvs_j_
.byte $10 ; 11/0b ___rvs_k___
.byte $10 ; 12/0c ___rvs_l___
.byte $10 ; 29/1d ___rvs_]___
.byte $10 ; 30/1e ___rvs_^___
.byte $10 ; 31/1f _rvs_under_
- .byte $A0 ; 32/20 ___SPACE___
+ .byte $A0 ; 32/20 ___SPACE___
.byte $00 ; 33/21 _____!_____
.byte $00 ; 34/22 _____"_____
- .byte $00 ; 35/23 _____#_____
+ .byte $00 ; 35/23 _____#_____
.byte $00 ; 36/24 _____$_____
.byte $00 ; 37/25 _____%_____
.byte $00 ; 38/26 _____&_____
.byte $00 ; 42/2a _____*_____
.byte $00 ; 43/2b _____+_____
.byte $00 ; 44/2c _____,_____
- .byte $00 ; 45/2d _____-_____
+ .byte $00 ; 45/2d _____-_____
.byte $00 ; 46/2e _____._____
- .byte $00 ; 47/2f _____/_____
+ .byte $00 ; 47/2f _____/_____
.byte $0C ; 48/30 _____0_____
.byte $0C ; 49/31 _____1_____
.byte $0C ; 50/32 _____2_____
.byte $00 ; 63/3f _____?_____
.byte $00 ; 64/40 _____@_____
- .byte $09 ; 65/41 _____a_____
- .byte $09 ; 66/42 _____b_____
- .byte $09 ; 67/43 _____c_____
- .byte $09 ; 68/44 _____d_____
- .byte $09 ; 69/45 _____e_____
- .byte $09 ; 70/46 _____f_____
- .byte $01 ; 71/47 _____g_____
- .byte $01 ; 72/48 _____h_____
- .byte $01 ; 73/49 _____i_____
- .byte $01 ; 74/4a _____j_____
- .byte $01 ; 75/4b _____k_____
- .byte $01 ; 76/4c _____l_____
- .byte $01 ; 77/4d _____m_____
- .byte $01 ; 78/4e _____n_____
- .byte $01 ; 79/4f _____o_____
- .byte $01 ; 80/50 _____p_____
- .byte $01 ; 81/51 _____q_____
- .byte $01 ; 82/52 _____r_____
- .byte $01 ; 83/53 _____s_____
- .byte $01 ; 84/54 _____t_____
- .byte $01 ; 85/55 _____u_____
- .byte $01 ; 86/56 _____v_____
- .byte $01 ; 87/57 _____w_____
- .byte $01 ; 88/58 _____x_____
- .byte $01 ; 89/59 _____y_____
+ .byte $09 ; 65/41 _____a_____
+ .byte $09 ; 66/42 _____b_____
+ .byte $09 ; 67/43 _____c_____
+ .byte $09 ; 68/44 _____d_____
+ .byte $09 ; 69/45 _____e_____
+ .byte $09 ; 70/46 _____f_____
+ .byte $01 ; 71/47 _____g_____
+ .byte $01 ; 72/48 _____h_____
+ .byte $01 ; 73/49 _____i_____
+ .byte $01 ; 74/4a _____j_____
+ .byte $01 ; 75/4b _____k_____
+ .byte $01 ; 76/4c _____l_____
+ .byte $01 ; 77/4d _____m_____
+ .byte $01 ; 78/4e _____n_____
+ .byte $01 ; 79/4f _____o_____
+ .byte $01 ; 80/50 _____p_____
+ .byte $01 ; 81/51 _____q_____
+ .byte $01 ; 82/52 _____r_____
+ .byte $01 ; 83/53 _____s_____
+ .byte $01 ; 84/54 _____t_____
+ .byte $01 ; 85/55 _____u_____
+ .byte $01 ; 86/56 _____v_____
+ .byte $01 ; 87/57 _____w_____
+ .byte $01 ; 88/58 _____x_____
+ .byte $01 ; 89/59 _____y_____
.byte $01 ; 90/5a _____z_____
- .byte $00 ; 91/5b _____[_____
+ .byte $00 ; 91/5b _____[_____
.byte $00 ; 92/5c _____\_____
.byte $00 ; 93/5d _____]_____
.byte $00 ; 94/5e _____^_____
.byte $02 ; 121/79 _U`_grave__
.byte $02 ; 122/7a _U'_acute__
.byte $00 ; 123/7b _U^_circum_
- .byte $00 ; 124/7c _U"_dieres_
+ .byte $00 ; 124/7c _U"_dieres_
.byte $00 ; 125/7d _Y'_acute__
.byte $00 ; 126/7e _cap_thorn_
.byte $00 ; 127/7f _Es-sed_B__
.byte $00 ; 132/84 _tl_corner_
.byte $00 ; 133/85 _tr_corner_
.byte $00 ; 134/86 _bl_corner_
- .byte $00 ; 135/87 _br_corner_
+ .byte $00 ; 135/87 _br_corner_
.byte $00 ; 136/88 ___l_tee___
.byte $00 ; 137/89 ___r_tee___
.byte $00 ; 138/8a ___t_tee___
.byte $00 ; 165/a5 ____yen____
.byte $00 ; 166/a6 _|_broken__
.byte $00 ; 167/a7 __section__
- .byte $00 ; 168/a8 __umulaut__
+ .byte $00 ; 168/a8 __umulaut__
.byte $00 ; 169/a9 _copyright_
.byte $00 ; 170/aa __fem_ord__
.byte $00 ; 171/ab _l_ang_quo_
.byte $00 ; 177/b1 ____+/-____
.byte $00 ; 178/b2 _2_supersc_
.byte $00 ; 179/b3 _3_supersc_
- .byte $00 ; 180/b4 ___acute___
+ .byte $00 ; 180/b4 ___acute___
.byte $00 ; 181/b5 ____mu_____
.byte $00 ; 182/b6 _paragraph_
.byte $00 ; 183/b7 __mid_dot__
.byte $00 ; 209/d1 _____Q_____
.byte $00 ; 210/d2 _____R_____
.byte $00 ; 211/d3 _____S_____
- .byte $00 ; 212/d4 _____T_____
+ .byte $00 ; 212/d4 _____T_____
.byte $00 ; 213/d5 _____U_____
.byte $00 ; 214/d6 _____V_____
.byte $00 ; 215/d7 _____W_____
.byte $00 ; 221/dd _____}_____
.byte $00 ; 222/de _____~_____
.byte $00 ; 223/df ___HOUSE___
- .byte $00 ; 224/e0 _a`_grave__
+ .byte $00 ; 224/e0 _a`_grave__
.byte $00 ; 225/e1 _a'_acute__
.byte $00 ; 226/e2 _a^_circum_
.byte $00 ; 227/e3 _a~_tilde__
.byte $00 ; 253/fd _y'_acute__
.byte $00 ; 254/fe _sm_thorn__
.byte $00 ; 255/ff _y"_dieres_
-
.include "geossym2.inc"
_get_ostype:
- ldx #0
- lda version
- cmp #$a9
- beq geos11
- and #%11110000
- cmp #$10
- beq geos10
- lda c128Flag ; we're on at least 2.0
- cmp #$18
- beq geos_on_plus4
- ora version
- rts
+ ldx #0
+ lda version
+ cmp #$a9
+ beq geos11
+ and #%11110000
+ cmp #$10
+ beq geos10
+ lda c128Flag ; we're on at least 2.0
+ cmp #$18
+ beq geos_on_plus4
+ ora version
+ rts
geos10:
- lda version
- rts
+ lda version
+ rts
geos11:
- lda #$11
- rts
+ lda #$11
+ rts
geos_on_plus4:
- lda #$04
- rts
+ lda #$04
+ rts
_get_tv:
- jsr _get_ostype
- cmp #$04
- beq plus4_get_tv
- bpl only40 ; C64 with 40 columns only
- lda graphMode
- bpl only40 ; C128 but currently on 40 columns
- ldx #1 ; COLUMNS80
- bne tvmode
-only40: ldx #0 ; COLUMNS40
-tvmode: ; PAL/NTSC check here, result in A
- php
- sei ; disable interrupts
- lda CPU_DATA ; this is for C64
- pha
- lda #IO_IN ; enable access to I/O
- sta CPU_DATA
- bit rasreg
- bpl tvmode ; wait for rasterline 127<x<256
- lda #24 ; (rasterline now >=256!)
+ jsr _get_ostype
+ cmp #$04
+ beq plus4_get_tv
+ bpl only40 ; C64 with 40 columns only
+ lda graphMode
+ bpl only40 ; C128 but currently on 40 columns
+ ldx #1 ; COLUMNS80
+ bne tvmode
+only40: ldx #0 ; COLUMNS40
+tvmode: ; PAL/NTSC check here, result in A
+ php
+ sei ; disable interrupts
+ lda CPU_DATA ; this is for C64
+ pha
+ lda #IO_IN ; enable access to I/O
+ sta CPU_DATA
+ bit rasreg
+ bpl tvmode ; wait for rasterline 127<x<256
+ lda #24 ; (rasterline now >=256!)
modelp:
- cmp rasreg ; wait for rasterline = 24 (or 280 on PAL)
- bne modelp
- lda grcntrl1 ; 24 or 280 ?
- bpl ntsc
- lda #0 ; PAL
- beq modeend
+ cmp rasreg ; wait for rasterline = 24 (or 280 on PAL)
+ bne modelp
+ lda grcntrl1 ; 24 or 280 ?
+ bpl ntsc
+ lda #0 ; PAL
+ beq modeend
ntsc:
- lda #$80 ; NTSC
+ lda #$80 ; NTSC
modeend:
- stx tmp1
- ora tmp1
- sta tmp1
- ldx #0
- pla
- sta CPU_DATA ; restore memory config
- plp ; restore interrupt state
- lda tmp1
- rts
+ stx tmp1
+ ora tmp1
+ sta tmp1
+ ldx #0
+ pla
+ sta CPU_DATA ; restore memory config
+ plp ; restore interrupt state
+ lda tmp1
+ rts
plus4_get_tv:
- ldx #1 ; Assume PAL
- bit $FF07 ; Test bit 6
- bvc plus4pal
- dex ; NTSC
+ ldx #1 ; Assume PAL
+ bit $FF07 ; Test bit 6
+ bvc plus4pal
+ dex ; NTSC
plus4pal:
- txa
- ldx #0
- rts
+ txa
+ ldx #0
+ rts
.include "jumptab.inc"
-_InitForIO = InitForIO
+_InitForIO = InitForIO
-_DoneWithIO = DoneWithIO
\ No newline at end of file
+_DoneWithIO = DoneWithIO
\ No newline at end of file
.include "jumptab.inc"
-_ToBASIC = ToBASIC
\ No newline at end of file
+_ToBASIC = ToBASIC
\ No newline at end of file