2000-12-03 23:39:22 +00:00
|
|
|
;
|
2004-06-03 19:43:11 +00:00
|
|
|
; Christian Groessler, June 2004
|
2000-12-03 23:39:22 +00:00
|
|
|
;
|
|
|
|
; this file provides an equivalent to the BASIC GRAPHICS function
|
|
|
|
;
|
2004-06-03 19:43:11 +00:00
|
|
|
; int __fastcall__ _graphics(unsigned char mode);
|
2001-10-06 22:36:48 +00:00
|
|
|
;
|
|
|
|
;
|
2000-12-03 23:39:22 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export __graphics
|
2000-12-03 23:39:22 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.import findfreeiocb
|
2013-07-09 21:39:42 +00:00
|
|
|
.import __oserror
|
2013-05-09 11:56:54 +00:00
|
|
|
.import fddecusage
|
|
|
|
.import clriocb
|
|
|
|
.import fdtoiocb
|
|
|
|
.import newfd
|
2013-07-09 21:39:42 +00:00
|
|
|
.import scrdev
|
2013-05-09 11:56:54 +00:00
|
|
|
.importzp tmp1,tmp2,tmp3
|
2000-12-03 23:39:22 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "atari.inc"
|
|
|
|
.include "errno.inc"
|
2000-12-03 23:39:22 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.code
|
2000-12-03 23:39:22 +00:00
|
|
|
|
2001-10-06 22:36:48 +00:00
|
|
|
; set new grapics mode
|
|
|
|
; gets new mode in A
|
|
|
|
; returns handle or -1 on error
|
|
|
|
; uses tmp1, tmp2, tmp3, tmp4 (in subroutines)
|
2000-12-03 23:39:22 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.proc __graphics
|
|
|
|
|
|
|
|
; tax
|
|
|
|
; and #15 ; get required graphics mode
|
|
|
|
; cmp #12
|
|
|
|
; bcs invmode ; invalid mode
|
|
|
|
; txa
|
|
|
|
; and #$c0 ; invalid bits set?
|
|
|
|
; bne invmode
|
|
|
|
|
|
|
|
; stx tmp1
|
|
|
|
sta tmp1 ; remember graphics mode
|
|
|
|
|
|
|
|
parmok: jsr findfreeiocb
|
|
|
|
beq iocbok ; we found one
|
|
|
|
|
|
|
|
lda #<EMFILE ; "too many open files"
|
|
|
|
seterr: jsr __mappederrno ; @@@ probably not correct to set errno here @@@
|
|
|
|
rts ; return -1
|
|
|
|
|
|
|
|
;invmode:ldx #>EINVAL
|
|
|
|
; lda #<EINVAL
|
|
|
|
; bne seterr
|
|
|
|
|
|
|
|
iocbok: txa
|
|
|
|
tay ; move iocb # into Y
|
|
|
|
lda #3
|
|
|
|
sta tmp3 ; name length + 1
|
|
|
|
lda #<scrdev
|
|
|
|
ldx #>scrdev
|
|
|
|
jsr newfd
|
|
|
|
tya
|
|
|
|
tax
|
|
|
|
bcs doopen ; C set: open needed
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
lda tmp2 ; get fd used
|
|
|
|
jsr fdtoiocb
|
|
|
|
tax
|
|
|
|
|
|
|
|
doopen: txa
|
|
|
|
;brk
|
|
|
|
pha
|
|
|
|
jsr clriocb
|
|
|
|
pla
|
|
|
|
tax
|
|
|
|
lda #<scrdev
|
|
|
|
sta ICBAL,x
|
|
|
|
lda #>scrdev
|
|
|
|
sta ICBAH,x
|
|
|
|
lda #OPEN
|
|
|
|
sta ICCOM,x
|
|
|
|
lda tmp1 ; get requested graphics mode
|
|
|
|
and #15
|
|
|
|
sta ICAX2,x
|
|
|
|
lda tmp1
|
|
|
|
and #$30
|
|
|
|
eor #$10
|
|
|
|
ora #12
|
|
|
|
sta ICAX1,x
|
|
|
|
|
|
|
|
jsr CIOV
|
|
|
|
bmi cioerr
|
|
|
|
|
|
|
|
lda tmp2 ; get fd
|
|
|
|
ldx #0
|
|
|
|
stx __oserror
|
|
|
|
rts
|
|
|
|
|
2013-07-09 21:39:42 +00:00
|
|
|
cioerr: sty tmp3 ; remember error code
|
|
|
|
lda #CLOSE
|
|
|
|
sta ICCOM,x
|
|
|
|
jsr CIOV ; close IOCB again since open failed
|
|
|
|
jsr fddecusage ; and decrement usage counter of fd
|
|
|
|
lda tmp3 ; put error code into A
|
|
|
|
jmp __mappederrno
|
2013-05-09 11:56:54 +00:00
|
|
|
|
|
|
|
.endproc ; __graphics
|