From d93f84f4bc079e9ea20542a492101bf4dc3730ec Mon Sep 17 00:00:00 2001 From: Marco van den Heuvel Date: Tue, 13 Feb 2018 19:19:40 -0800 Subject: [PATCH 1/2] Improved GeOS version detection. --- include/geos/gsys.h | 2 + libsrc/geos-cbm/geossym2.inc | 2 + libsrc/geos-cbm/system/get_ostype.s | 18 ++++++++- samples/geos/geosver.c | 58 +++++++++++++++++++++++++++++ samples/geos/geosverres.grc | 8 ++++ 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 samples/geos/geosver.c create mode 100644 samples/geos/geosverres.grc diff --git a/include/geos/gsys.h b/include/geos/gsys.h index 284c38b63..b60c9884b 100644 --- a/include/geos/gsys.h +++ b/include/geos/gsys.h @@ -31,6 +31,8 @@ char get_ostype(void); #define GEOS4 0x04 /* plus4 geos is not or'ed with version */ #define GEOS128 0x80 /* version flags */ +#define MEGAPATCH3 0x03 +#define GATEWAY 0x08 #define GEOS_V10 0x10 #define GEOS_V11 0x11 #define GEOS_V12 0x12 /* ??? not sure */ diff --git a/libsrc/geos-cbm/geossym2.inc b/libsrc/geos-cbm/geossym2.inc index cdcbc24dc..c756280a9 100644 --- a/libsrc/geos-cbm/geossym2.inc +++ b/libsrc/geos-cbm/geossym2.inc @@ -4,8 +4,10 @@ ;4-2-99 bootName = $c006 +gatewayFlag = $c007 version = $c00f nationality = $c010 sysFlgCopy = $c012 c128Flag = $c013 +mp3Flag = $c014 dateCopy = $c018 \ No newline at end of file diff --git a/libsrc/geos-cbm/system/get_ostype.s b/libsrc/geos-cbm/system/get_ostype.s index 492ce132d..827630f0b 100644 --- a/libsrc/geos-cbm/system/get_ostype.s +++ b/libsrc/geos-cbm/system/get_ostype.s @@ -3,8 +3,8 @@ ; ; 10.09.2001 ; -; Plus4 and GEOS 1.1 detection by -; Marco van den Heuvel, 2010-02-02 +; Plus4, Gateway, MP3 and GEOS 1.1 detection by +; Marco van den Heuvel, 2018-02-07 ; ; unsigned char get_ostype (void); @@ -26,6 +26,12 @@ _get_ostype: and #%11110000 cmp #$10 beq geos10 + lda gatewayFlag + cmp #$41 + beq gateway + lda mp3Flag + cmp #$4d + beq megapatch3 lda c128Flag ; we're on at least 2.0 cmp #$18 beq geos_on_plus4 @@ -40,6 +46,14 @@ geos11: geos_on_plus4: lda #$04 rts +gateway: + lda #$08 + ora c128Flag + rts +megapatch3: + lda #$03 + ora c128Flag + rts _get_tv: jsr _get_ostype diff --git a/samples/geos/geosver.c b/samples/geos/geosver.c new file mode 100644 index 000000000..673b7e1f7 --- /dev/null +++ b/samples/geos/geosver.c @@ -0,0 +1,58 @@ +#include +#include + +// Let's define the window we're operating +struct window wholeScreen = {0, SC_PIX_HEIGHT-1, 0, SC_PIX_WIDTH-1}; + + +void main (void) +{ + unsigned char os = get_ostype(); + unsigned char *machine = NULL; + unsigned char *version = NULL; + unsigned char good = 1; + + SetPattern(0); + InitDrawWindow(&wholeScreen); + Rectangle(); + gotoxy(0, 4); + if (os == GEOS4) { + machine = "plus4"; + version = "GeOS v3.5"; + } else { + if ((os & GEOS128) == GEOS128) { + machine = "c128"; + } else { + machine = "c64"; + } + os &= 0x7f; + if (os == GEOS_V10) { + version = "GeOS v1.0"; + } else if (os == GEOS_V11) { + version = "GeOS v1.1"; + } else if (os == GEOS_V12) { + version = "GeOS v1.2"; + } else if (os == GEOS_V20) { + version = "GeOS v2.0"; + } else if (os == MEGAPATCH3) { + version = "MegaPatch 3"; + } else if (os == GATEWAY) { + version = "GateWay"; + } else if ((os & WHEELS) == WHEELS) { + version = "Wheels"; + } else { + version = "Unknown GeOS version"; + good = 0; + } + } + + if (good) { + cprintf("%s (%s)", version, machine); + } else { + cprintf("%s (%s) (%d)", version, machine, os); + } + + Sleep(10*50); + + return; +} diff --git a/samples/geos/geosverres.grc b/samples/geos/geosverres.grc new file mode 100644 index 000000000..cac9ed698 --- /dev/null +++ b/samples/geos/geosverres.grc @@ -0,0 +1,8 @@ + +; this is the resource file for geosver.c, a GEOS application example + +HEADER APPLICATION "geosver" "GeOSver" "V1.0" { +dostype USR +author "Marco van den Heuvel" +info "This is a C prog compiled with cc65 and GEOSLib." +} From e17b9177dea44ed453a1ad77e0c9a2ea9569938d Mon Sep 17 00:00:00 2001 From: Marco van den Heuvel Date: Wed, 14 Feb 2018 10:22:10 -0800 Subject: [PATCH 2/2] Fixed GeOS -> GEOS and added newline to geossym2.inc. --- libsrc/geos-cbm/geossym2.inc | 3 ++- samples/geos/geosver.c | 12 ++++++------ samples/geos/geosverres.grc | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libsrc/geos-cbm/geossym2.inc b/libsrc/geos-cbm/geossym2.inc index c756280a9..02a2fd44b 100644 --- a/libsrc/geos-cbm/geossym2.inc +++ b/libsrc/geos-cbm/geossym2.inc @@ -10,4 +10,5 @@ nationality = $c010 sysFlgCopy = $c012 c128Flag = $c013 mp3Flag = $c014 -dateCopy = $c018 \ No newline at end of file +dateCopy = $c018 + diff --git a/samples/geos/geosver.c b/samples/geos/geosver.c index 673b7e1f7..77a15ada7 100644 --- a/samples/geos/geosver.c +++ b/samples/geos/geosver.c @@ -18,7 +18,7 @@ void main (void) gotoxy(0, 4); if (os == GEOS4) { machine = "plus4"; - version = "GeOS v3.5"; + version = "GEOS v3.5"; } else { if ((os & GEOS128) == GEOS128) { machine = "c128"; @@ -27,13 +27,13 @@ void main (void) } os &= 0x7f; if (os == GEOS_V10) { - version = "GeOS v1.0"; + version = "GEOS v1.0"; } else if (os == GEOS_V11) { - version = "GeOS v1.1"; + version = "GEOS v1.1"; } else if (os == GEOS_V12) { - version = "GeOS v1.2"; + version = "GEOS v1.2"; } else if (os == GEOS_V20) { - version = "GeOS v2.0"; + version = "GEOS v2.0"; } else if (os == MEGAPATCH3) { version = "MegaPatch 3"; } else if (os == GATEWAY) { @@ -41,7 +41,7 @@ void main (void) } else if ((os & WHEELS) == WHEELS) { version = "Wheels"; } else { - version = "Unknown GeOS version"; + version = "Unknown GEOS version"; good = 0; } } diff --git a/samples/geos/geosverres.grc b/samples/geos/geosverres.grc index cac9ed698..9a3d72a26 100644 --- a/samples/geos/geosverres.grc +++ b/samples/geos/geosverres.grc @@ -1,7 +1,7 @@ ; this is the resource file for geosver.c, a GEOS application example -HEADER APPLICATION "geosver" "GeOSver" "V1.0" { +HEADER APPLICATION "geosver" "GEOSver" "V1.0" { dostype USR author "Marco van den Heuvel" info "This is a C prog compiled with cc65 and GEOSLib."