2 ; Christian Groessler, October 2001
4 ; this file provides an equivalent to the BASIC GRAPHICS function
6 ; int __fastcall__ graphics(unsigned char mode);
11 .constructor initscrmem,28
14 .import __seterrno,__do_oserror,__oserror
19 .import __graphmode_used
20 .importzp tmp1,tmp2,tmp3
27 ; set new grapics mode
29 ; returns handle or -1 on error
30 ; uses tmp1, tmp2, tmp3, tmp4 (in subroutines)
35 ; and #15 ; get required graphics mode
37 ; bcs invmode ; invalid mode
39 ; and #$c0 ; invalid bits set?
43 sta tmp1 ; remember graphics mode
45 parmok: jsr findfreeiocb
46 beq iocbok ; we found one
48 lda #<EMFILE ; "too many open files"
50 seterr: jsr __seterrno
60 tay ; move iocb # into Y
62 sta tmp3 ; name length + 1
68 bcs doopen ; C set: open needed
71 lda tmp2 ; get fd used
87 lda tmp1 ; get requested graphics mode
104 cioerr: jsr fddecusage ; decrement usage counter of fd as open failed
110 ; calc. upper memory limit to use
115 beq ignore ; mode 0 doesn't need adjustment
117 bcs ignore ; invalid value
130 .endproc ; initscrmem
134 scrdev: .byte "S:", 0
137 ; memory usage of the different graphics modes (0-31)
138 ; values < 0 of "bytes needed" are mappped to 0
139 ; bytes needed ; mode ; val. of MEMTOP
142 .word 0 ;-318 ; 1 ; 40285
143 .word 0 ;-568 ; 2 ; 40535
144 .word 0 ;-558 ; 3 ; 40525
145 .word 0 ;-298 ; 4 ; 40265
146 .word 182 ; 5 ; 39785
147 .word 1182 ; 6 ; 38785
148 .word 3198 ; 7 ; 36769
149 .word 7120 ; 8 ; 32847
150 .word 7146 ; 9 ; 32821
151 .word 7146 ; 10 ; 32821
152 .word 7146 ; 11 ; 32821
153 .word 162 ; 12 ; 39805
154 .word 0 ;-328 ; 13 ; 40295
155 .word 3278 ; 14 ; 36689
156 .word 7120 ; 15 ; 32847
158 .word 0 ;-320 ; 17 ; 40287
159 .word 0 ;-572 ; 18 ; 40539
160 .word 0 ;-560 ; 19 ; 40527
161 .word 0 ;-296 ; 20 ; 40263
162 .word 184 ; 21 ; 39783
163 .word 1192 ; 22 ; 38775
164 .word 3208 ; 23 ; 36759
165 .word 7146 ; 24 ; 32821
166 .word 7146 ; 25 ; 32821
167 .word 7146 ; 26 ; 32821
168 .word 7146 ; 27 ; 32821
169 .word 160 ; 28 ; 39807
170 .word 0 ;-332 ; 29 ; 40299
171 .word 3304 ; 30 ; 36663
172 .word 7146 ; 31 ; 32821
174 ; the program used to get these values (Atari BASIC):
176 ; 110 IF FILE=1 THEN OPEN #1,8,0,"D:FREEMEM.OUT"
177 ; 120 IF FILE<>1 THEN OPEN #1,8,0,"E:"
179 ; 210 FOR I=0 TO 32:GRAPHICS I:GOSUB 1000:G(I)=VAL:NEXT I
181 ; 230 FOR I=0 TO 31:PRINT #1;I;":",G(I);" - ";G(0)-G(I):NEXT I
184 ; 1000 VAL=PEEK(741)+256*PEEK(742)