dio bugfix, added get_tv and get_ostype functions

git-svn-id: svn://svn.cc65.org/cc65/trunk@889 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
izydorst 2001-09-10 21:43:15 +00:00
parent 1da6f339dc
commit 490e3b8c0f
6 changed files with 103 additions and 12 deletions

View file

@ -537,7 +537,8 @@ description of bits in return values - they describe the position in detail.
<sect2>Sprites
<p>
You are free to use any of the eight sprites, but keep in mind that sprite 0 is actually the mouse
pointer and sprite 1 can be overwritten when using text prompt.
pointer and sprite 1 can be overwritten when using text prompt. You don't have to worry about
40/80 column issues because GEOS128 has pretty good sprite emulator for VDC.
<sect3>DrawSprite
<p>
@ -578,7 +579,7 @@ range 1-48.
<p>
<tt/void PromptOff (void)/
<p>
The first function places text prompt in given place and enables its blinking
The first function places text prompt in given place and enables blinking.
The second one is pretty self-explanatory.
<sect3>GetNextChar
@ -616,7 +617,7 @@ These functions are taking single data sector (256 bytes) to read or write on a
<p>
<tt/char WriteBuff (struct tr_se *myTrSe)/
<p>
These functions are reading and writting sector placed at <tt/diskBlkBuf/.
These functions read and write sector placed at <tt/diskBlkBuf/.
<sect3>GetBlock and ReadBlock
<p>
@ -694,7 +695,7 @@ In fact, this function could be used in a following way:
<tscreen><verb>
&num;define BlockInUse FindBAMBit
...
if (!SectInUse(&amp;myTrSe)) &lcub;
if (!BlockInUse(&amp;myTrSe)) &lcub;
... block not allocated ...
&rcub;
</verb></tscreen>
@ -927,7 +928,7 @@ E.g. size of whole VLIR file can be retrieved by reading <tt/VLIRInfo.fileSize/.
<p>
<tt/char OpenRecordFile (char *fName)/
<p>
This function finds and opens given file. An error is returned if file is not found or it is not
This function finds and opens given file. An error is returned if file is not found or if it is not
in VLIR format. Information in <tt/VLIRInfo/ is initialized. VLIR track and sector table is
loaded at <tt/fileTrScTab/ and will be valid until call to <tt/CloseRecordFile/ so don't modify it.
You should <tt/PointRecord/ before trying to do something with file.
@ -942,8 +943,8 @@ This function calls <tt/UpdateRecordFile/ and clears internal GEOS variables.
<p>
<tt/char UpdateRecordFile (void)/
<p>
This function fill check <tt/VLIRInfo.fileWritten/ flag and if it is set, then <tt/curDirHead/ will
be updated along with size and date stamps in directory entry.
This function will check <tt/VLIRInfo.fileWritten/ flag and if it is set, then <tt/curDirHead/ is
updated along with size and date stamps in directory entry.
<sect3>PointRecord
<p>
@ -1234,6 +1235,26 @@ This function sets current device to given. It might be used together with <tt/I
<tt/DoneWithIO/ and some Kernal routines. Unless new device is a disk drive this only sets
new value in <tt/curDevice/, in other case new disk driver is loaded from REU or internal RAM.
<sect2>get_ostype
<p>
<tt/char get_ostype (void)/
<p>
This function returns GEOS Kernal version combined (by logical OR) with machine type. Read
<tt/gsys.h/ for definitions of returned values.
<sect2>get_tv
<p>
<tt/char get_tv (void)/
<p>
This function returns PAL/NTSC flag combined (by logical OR) with 40/80 columns flag. This is
not the best way to check if screen has 40 or 80 columns since PAL/NTSC check is always
performed and it can take as long as full raster frame. If you just want to know if
screen has 40 or 80 columns use expression <tt/graphMode & 0x80/ which returns <tt/0/ for
40 columns and <tt/0x80/ for 80 columns. Remember that this parameter can be changed during
runtime. It is unclear if this will work for GEOS 64 so you probably do not want to test
anything if not running under GEOS128. Use <tt/get_ostype/ to check it. Read <tt/gsys.h/ for
definitions of returned values.
<sect>Library Structures
<p>
To simplify usage and optimize passing parameters to functions I have declared several structures

View file

@ -2,7 +2,7 @@
GEOS system functions
ported to small C on 27.10.1999
by Maciej 'YTM/Alliance' Witkowiak
by Maciej 'YTM/Elysium' Witkowiak
*/
#ifndef _GSYS_H
@ -23,4 +23,21 @@ char __fastcall__ GetRandom(void);
void __fastcall__ SetDevice(char newdev);
char __fastcall__ get_ostype(void);
/* possible return values of get_ostype, machine and version flags will
be combined */
#define GEOS64 0x00
#define GEOS128 0x80
#define GEOS_V10 0x10
#define GEOS_V12 0x12 /* ??? not sure */
#define GEOS_V20 0x20
char __fastcall__ get_tv(void);
/* possible return values of get_tv, these flags will be combined
note that columns state can be changed during runtime */
#define COLUMNS40 0x00
#define COLUMNS80 0x01
#define TV_PAL 0x00
#define TV_NTSC 0x80
#endif

View file

@ -38,6 +38,7 @@
ldy #diopp_head
lda (ptr2),y
bne _inv_data ; there is only head 0
ldy #diopp_track
lda (ptr2),y
@ -53,7 +54,7 @@
iny
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
@ -67,7 +68,7 @@
beq dio_cts1571
cmp #DRV_1581
beq dio_cts1581
; unknown device, return what you have got
dio_ctsend:

View file

@ -29,7 +29,8 @@ sectsizetab:
pha
tax
lda driveType,x ; check if there's a device
bne _inv_drive
beq _inv_drive
txa
clc
adc #8 ; normalize devnum
sta curDevice

View file

@ -9,7 +9,7 @@
S_OBJS = callroutine.o enterdesktop.o firstinit.o getrandom.o getserialnumber.o\
initdoneio.o mainloop.o panic.o tobasic.o setdevice.o
initdoneio.o mainloop.o panic.o tobasic.o setdevice.o get_ostype.o
all: $(S_OBJS)

View file

@ -0,0 +1,51 @@
;
; Maciej 'YTM/Elysium' Witkowiak
;
; 10.09.2001
; unsigned char get_ostype (void);
; unsigned char get_tv (void);
.export get_ostype
.export get_tv
.import tmp1
.include "../inc/geossym.inc"
.include "../inc/geossym2.inc"
get_ostype:
lda version
and #%11110000
cmp #$10
beq geos10
lda c128Flag ; we're on at least 2.0
ora version
rts
geos10:
lda version
rts
get_tv:
jsr get_ostype
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
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
ntsc: lda #$80 ; NTSC
modeend: stx tmp1
ora tmp1
rts