From: cpg Date: Sat, 6 Oct 2001 22:36:48 +0000 (+0000) Subject: implemented graphics() function X-Git-Tag: V2.12.0~2577 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=404dd3ca412c7b179849430f16fb4dc563901c03;p=cc65 implemented graphics() function git-svn-id: svn://svn.cc65.org/cc65/trunk@1013 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/atari/graphics.s b/libsrc/atari/graphics.s index 94dea3bd6..57ef2b07a 100644 --- a/libsrc/atari/graphics.s +++ b/libsrc/atari/graphics.s @@ -1,25 +1,109 @@ ; -; Christian Groessler, December 2000 +; Christian Groessler, October 2001 ; ; this file provides an equivalent to the BASIC GRAPHICS function ; -; void __fastcall__ graphics(unsigned char mode); +; int __fastcall__ graphics(unsigned char mode); +; +; .export _graphics .constructor initscrmem,28 + .import findfreeiocb + .import __seterrno,__do_oserror,__oserror + .import fddecusage + .import clriocb + .import fdtoiocb + .import newfd .import __graphmode_used + .importzp tmp1,tmp2,tmp3 .include "atari.inc" + .include "../common/errno.inc" .code +; set new grapics mode +; gets new mode in A +; returns handle or -1 on error +; uses tmp1, tmp2, tmp3, tmp4 (in subroutines) .proc _graphics - rts ; not implemented yet! - -.endproc +; 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 +seterr: jsr __seterrno + lda #$FF + tax + rts ; return -1 + +;invmode:ldx #>EINVAL +; lda #scrdev + jsr newfd + tya + tax + bcs doopen ; C set: open needed + + ldx #0 + lda tmp2 ; get fd used + jsr fdtoiocb + +doopen: txa + ;brk + pha + jsr clriocb + pla + tax + 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 + +cioerr: jsr fddecusage ; decrement usage counter of fd as open failed + jmp __do_oserror + +.endproc ; _graphics ; calc. upper memory limit to use @@ -42,10 +126,13 @@ sta APPMHI+1 ignore: rts -.endproc +.endproc ; initscrmem .rodata +scrdev: .byte "S:", 0 + + ; memory usage of the different graphics modes (0-31) ; values < 0 of "bytes needed" are mappped to 0 ; bytes needed ; mode ; val. of MEMTOP