From 40e93dd931a9d9893f29490a434d28a64b830289 Mon Sep 17 00:00:00 2001 From: Marco van den Heuvel Date: Mon, 5 Mar 2018 15:01:55 -0800 Subject: [PATCH 1/3] Improved reu size detection. --- libsrc/c128/emd/c128-reu.s | 59 ++++++++++++++++++++++++++++++------- libsrc/c64/emd/c64-reu.s | 60 +++++++++++++++++++++++++++++++------- 2 files changed, 99 insertions(+), 20 deletions(-) diff --git a/libsrc/c128/emd/c128-reu.s b/libsrc/c128/emd/c128-reu.s index a858c591e..3b191c666 100644 --- a/libsrc/c128/emd/c128-reu.s +++ b/libsrc/c128/emd/c128-reu.s @@ -92,17 +92,56 @@ INSTALL: cmp REU_REUADDR ; Check for presence of REU bne nodevice - ldy #>(128*4) ; Assume 128KB - lda REU_STATUS - and #$10 ; Check size bit - beq @L1 - ldy #>(256*4) ; 256KB when size bit is set -@L1: sty pagecount+1 - +; determine the size + php + sei ldy #$FF - sty curpage - sty curpage+1 ; Invalidate the current page - txa ; X = A = EM_ERR_OK +loop: + sty window + jsr reu_size_check_common + ldx #%10110000 + stx REU_COMMAND + dey + cpy #$FF + bne loop + iny +size_loop: + jsr reu_size_check_common + ldx #%10110001 + stx REU_COMMAND + cpy window + bne size_found + iny + bne size_loop +size_found: + plp + ldx #$00 + cpy #$00 ; too many pages, shave off 2 + bne pagecount_ok + dex + dex + dey +pagecount_ok: + stx pagecount + sty pagecount+1 + lda #EM_ERR_OK + rts + +; common REU setup for size check +reu_size_check_common: + sty REU_REUADDR+2 + ldx #window + stx REU_C64ADDR+1 + ldx #$00 + stx REU_REUADDR + stx REU_REUADDR+1 + stx REU_COUNT+1 + stx REU_CONTROL + inx + stx REU_COUNT rts ; No REU found diff --git a/libsrc/c64/emd/c64-reu.s b/libsrc/c64/emd/c64-reu.s index 0779505be..5bbed2f3a 100644 --- a/libsrc/c64/emd/c64-reu.s +++ b/libsrc/c64/emd/c64-reu.s @@ -92,19 +92,59 @@ INSTALL: cmp REU_REUADDR ; Check for presence of REU bne nodevice - ldy #>(128*4) ; Assume 128KB - lda REU_STATUS - and #$10 ; Check size bit - beq @L1 - ldy #>(256*4) ; 256KB when size bit is set -@L1: sty pagecount+1 - +; determine the size + php + sei ldy #$FF - sty curpage - sty curpage+1 ; Invalidate the current page - txa ; X = A = EM_ERR_OK +loop: + sty window + jsr reu_size_check_common + ldx #%10110000 + stx REU_COMMAND + dey + cpy #$FF + bne loop + iny +size_loop: + jsr reu_size_check_common + ldx #%10110001 + stx REU_COMMAND + cpy window + bne size_found + iny + bne size_loop +size_found: + plp + ldx #$00 + cpy #$00 ; too many pages, shave off 2 + bne pagecount_ok + dex + dex + dey +pagecount_ok: + stx pagecount + sty pagecount+1 + lda #EM_ERR_OK rts +; common REU setup for size check +reu_size_check_common: + sty REU_REUADDR+2 + ldx #window + stx REU_C64ADDR+1 + ldx #$00 + stx REU_REUADDR + stx REU_REUADDR+1 + stx REU_COUNT+1 + stx REU_CONTROL + inx + stx REU_COUNT + rts + + ; No REU found nodevice: From b78328057722e68df7d110056af016abbe9c9f7e Mon Sep 17 00:00:00 2001 From: Marco van den Heuvel Date: Mon, 5 Mar 2018 17:46:51 -0800 Subject: [PATCH 2/3] Replaced reu commands with defined constants. --- libsrc/c128/emd/c128-reu.s | 6 ++++-- libsrc/c64/emd/c64-reu.s | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libsrc/c128/emd/c128-reu.s b/libsrc/c128/emd/c128-reu.s index 3b191c666..3ded00d67 100644 --- a/libsrc/c128/emd/c128-reu.s +++ b/libsrc/c128/emd/c128-reu.s @@ -55,6 +55,8 @@ REU_TRIGGER = $FF00 ; REU command trigger OP_COPYFROM = $ED OP_COPYTO = $EC +OP_COPYFROM_ALOAD = $B1 +OP_COPYTO_ALOAD = $B0 ; ------------------------------------------------------------------------ ; Data. @@ -99,7 +101,7 @@ INSTALL: loop: sty window jsr reu_size_check_common - ldx #%10110000 + ldx #OP_COPYTO_ALOAD stx REU_COMMAND dey cpy #$FF @@ -107,7 +109,7 @@ loop: iny size_loop: jsr reu_size_check_common - ldx #%10110001 + ldx #OP_COPYFROM_ALOAD stx REU_COMMAND cpy window bne size_found diff --git a/libsrc/c64/emd/c64-reu.s b/libsrc/c64/emd/c64-reu.s index 5bbed2f3a..bf7bb4fb0 100644 --- a/libsrc/c64/emd/c64-reu.s +++ b/libsrc/c64/emd/c64-reu.s @@ -55,6 +55,9 @@ REU_TRIGGER = $FF00 ; REU command trigger OP_COPYFROM = $ED OP_COPYTO = $EC +OP_COPYFROM_ALOAD = $B1 +OP_COPYTO_ALOAD = $B0 + ; ------------------------------------------------------------------------ ; Data. @@ -99,7 +102,7 @@ INSTALL: loop: sty window jsr reu_size_check_common - ldx #%10110000 + ldx #OP_COPYTO_ALOAD stx REU_COMMAND dey cpy #$FF @@ -107,7 +110,7 @@ loop: iny size_loop: jsr reu_size_check_common - ldx #%10110001 + ldx #OP_COPYFROM_ALOAD stx REU_COMMAND cpy window bne size_found From 2418c0e0af7d070e0748c58cfa0f77ab54bff4a2 Mon Sep 17 00:00:00 2001 From: Marco van den Heuvel Date: Tue, 6 Mar 2018 18:00:36 -0800 Subject: [PATCH 3/3] Updated documentation for the reu emd. --- doc/c128.sgml | 6 ++---- doc/c64.sgml | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/doc/c128.sgml b/doc/c128.sgml index 460621be0..f133d8d4c 100644 --- a/doc/c128.sgml +++ b/doc/c128.sgml @@ -221,10 +221,8 @@ missing on VDC, and are translated to the two colors missing from the VIC palett Will test the hardware for the available RAM. - A driver for the CBM REUs. The driver will determine from the connected REU - if it supports 128KB of RAM or more. In the latter case, 256KB are assumed, - but since there are no range checks, the application can use more memory if - it has better knowledge about the hardware than the driver. + A driver for the CBM REUs. The driver will test the connected REU to find + out how much RAM is present. A driver for the VDC memory of the C128, written and contributed by Maciej diff --git a/doc/c64.sgml b/doc/c64.sgml index 9ab9b96c3..7cca1aa09 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -300,10 +300,8 @@ Note that the graphics drivers are incompatible with the Will test the hardware for the available RAM. - A driver for the CBM REUs. The driver will determine from the connected REU - if it supports 128KB of RAM or more. In the latter case, 256KB are assumed, - but since there are no range checks, the application can use more memory if - it has better knowledge about the hardware than the driver. + A driver for the CBM REUs. The driver will test the connected REU to find + out how much RAM is present. A driver for the VDC memory of the C128. Written and contributed by Maciej