From 490e3b8c0ffb7c3811c58ff3f4e96f31c6a08cf5 Mon Sep 17 00:00:00 2001 From: izydorst Date: Mon, 10 Sep 2001 21:43:15 +0000 Subject: [PATCH] dio bugfix, added get_tv and get_ostype functions git-svn-id: svn://svn.cc65.org/cc65/trunk@889 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- doc/geos.sgml | 35 +++++++++++++++++----- include/geos/gsys.h | 19 +++++++++++- libsrc/geos/disk/dio_cts.s | 5 ++-- libsrc/geos/disk/dio_openclose.s | 3 +- libsrc/geos/system/Makefile | 2 +- libsrc/geos/system/get_ostype.s | 51 ++++++++++++++++++++++++++++++++ 6 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 libsrc/geos/system/get_ostype.s diff --git a/doc/geos.sgml b/doc/geos.sgml index b1df8990b..5b6a09eb4 100644 --- a/doc/geos.sgml +++ b/doc/geos.sgml @@ -537,7 +537,8 @@ description of bits in return values - they describe the position in detail. Sprites

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. DrawSprite

@@ -578,7 +579,7 @@ range 1-48.

-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. GetNextChar @@ -616,7 +617,7 @@ These functions are taking single data sector (256 bytes) to read or write on a

-These functions are reading and writting sector placed at GetBlock and ReadBlock

@@ -694,7 +695,7 @@ In fact, this function could be used in a following way: #define BlockInUse FindBAMBit ... -if (!SectInUse(&myTrSe)) { +if (!BlockInUse(&myTrSe)) { ... block not allocated ... } @@ -927,7 +928,7 @@ E.g. size of whole VLIR file can be retrieved by reading -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 -This function fill check PointRecord

@@ -1234,6 +1235,26 @@ This function sets current device to given. It might be used together with get_ostype +

+ +This function returns GEOS Kernal version combined (by logical OR) with machine type. Read +get_tv +

+ +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 Library Structures

To simplify usage and optimize passing parameters to functions I have declared several structures diff --git a/include/geos/gsys.h b/include/geos/gsys.h index 028bf9c80..a367d255d 100644 --- a/include/geos/gsys.h +++ b/include/geos/gsys.h @@ -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 diff --git a/libsrc/geos/disk/dio_cts.s b/libsrc/geos/disk/dio_cts.s index 38f924573..f6118641e 100644 --- a/libsrc/geos/disk/dio_cts.s +++ b/libsrc/geos/disk/dio_cts.s @@ -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: diff --git a/libsrc/geos/disk/dio_openclose.s b/libsrc/geos/disk/dio_openclose.s index 8fb859018..3b798817b 100644 --- a/libsrc/geos/disk/dio_openclose.s +++ b/libsrc/geos/disk/dio_openclose.s @@ -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 diff --git a/libsrc/geos/system/Makefile b/libsrc/geos/system/Makefile index e761f581f..4b117ab66 100644 --- a/libsrc/geos/system/Makefile +++ b/libsrc/geos/system/Makefile @@ -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) diff --git a/libsrc/geos/system/get_ostype.s b/libsrc/geos/system/get_ostype.s new file mode 100644 index 000000000..bd40b5bf6 --- /dev/null +++ b/libsrc/geos/system/get_ostype.s @@ -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=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 -- 2.39.5