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
23 .include "../common/errno.inc"
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
86 lda tmp1 ; get requested graphics mode
103 cioerr: jsr fddecusage ; decrement usage counter of fd as open failed
109 ; calc. upper memory limit to use
114 beq ignore ; mode 0 doesn't need adjustment
116 bcs ignore ; invalid value
129 .endproc ; initscrmem
133 scrdev: .byte "S:", 0
136 ; memory usage of the different graphics modes (0-31)
137 ; values < 0 of "bytes needed" are mappped to 0
138 ; bytes needed ; mode ; val. of MEMTOP
141 .word 0 ;-318 ; 1 ; 40285
142 .word 0 ;-568 ; 2 ; 40535
143 .word 0 ;-558 ; 3 ; 40525
144 .word 0 ;-298 ; 4 ; 40265
145 .word 182 ; 5 ; 39785
146 .word 1182 ; 6 ; 38785
147 .word 3198 ; 7 ; 36769
148 .word 7120 ; 8 ; 32847
149 .word 7146 ; 9 ; 32821
150 .word 7146 ; 10 ; 32821
151 .word 7146 ; 11 ; 32821
152 .word 162 ; 12 ; 39805
153 .word 0 ;-328 ; 13 ; 40295
154 .word 3278 ; 14 ; 36689
155 .word 7120 ; 15 ; 32847
157 .word 0 ;-320 ; 17 ; 40287
158 .word 0 ;-572 ; 18 ; 40539
159 .word 0 ;-560 ; 19 ; 40527
160 .word 0 ;-296 ; 20 ; 40263
161 .word 184 ; 21 ; 39783
162 .word 1192 ; 22 ; 38775
163 .word 3208 ; 23 ; 36759
164 .word 7146 ; 24 ; 32821
165 .word 7146 ; 25 ; 32821
166 .word 7146 ; 26 ; 32821
167 .word 7146 ; 27 ; 32821
168 .word 160 ; 28 ; 39807
169 .word 0 ;-332 ; 29 ; 40299
170 .word 3304 ; 30 ; 36663
171 .word 7146 ; 31 ; 32821
173 ; the program used to get these values (Atari BASIC):
175 ; 110 IF FILE=1 THEN OPEN #1,8,0,"D:FREEMEM.OUT"
176 ; 120 IF FILE<>1 THEN OPEN #1,8,0,"E:"
178 ; 210 FOR I=0 TO 32:GRAPHICS I:GOSUB 1000:G(I)=VAL:NEXT I
180 ; 230 FOR I=0 TO 31:PRINT #1;I;":",G(I);" - ";G(0)-G(I):NEXT I
183 ; 1000 VAL=PEEK(741)+256*PEEK(742)