diff --git a/Contributing.md b/Contributing.md
index 74e6ead17..eb26e920b 100644
--- a/Contributing.md
+++ b/Contributing.md
@@ -134,7 +134,22 @@ You can refer to Annex B of the ISO C99 standard ([here](https://www.open-std.or
* Hexadecimal number constants should be used except where decimal or binary numbers make much more sense in that constant's context.
* Hexadecimal letters should be upper-case.
* When you set two registers or two memory locations to an immediate 16-bit zero, you should use the expressions ```#<$0000``` and ```#>$0000``` (they make it obvious where you are putting the lower and upper bytes).
-* If a function is declared to return a char-sized value, it actually must return an integer-sized value. (When cc65 promotes a returned value, it sometimes assumes that the value already is an integer.)
+* If a function is declared to return a char-sized value, it actually must return an integer-sized value. (When cc65 promotes a returned value, it sometimes assumes that the value already is an integer.) This must be done in one of the following ways:
+
+ lda #RETURN_VALUE
+ ldx #0 ; return value is char
+
+or, if the value is 0, you can use:
+
+ lda #RETURN_VALUE
+ .assert RETURN_VALUE = 0
+ tax
+
+sometimes jumping to return0 could save a byte:
+
+ .assert RETURN_VALUE = 0
+ jmp return 0
+
* Functions, that are intended for a platform's system library, should be optimized as much as possible.
* Sometimes, there must be a trade-off between size and speed. If you think that a library function won't be used often, then you should make it small. Otherwise, you should make it fast.
* Comments that are put on the right side of instructions must be aligned (start in the same character columns).
diff --git a/libsrc/apple2/emd/a2.auxmem.s b/libsrc/apple2/emd/a2.auxmem.s
index 5ef2564b1..c582e9eec 100644
--- a/libsrc/apple2/emd/a2.auxmem.s
+++ b/libsrc/apple2/emd/a2.auxmem.s
@@ -73,7 +73,8 @@ INSTALL:
and #$f0
cmp #$80
bne @L1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ txa
rts
@L1: lda #EM_ERR_NO_DEVICE
; rts
diff --git a/libsrc/apple2/joy/a2.stdjoy.s b/libsrc/apple2/joy/a2.stdjoy.s
index 558013910..11be52eb4 100644
--- a/libsrc/apple2/joy/a2.stdjoy.s
+++ b/libsrc/apple2/joy/a2.stdjoy.s
@@ -71,8 +71,9 @@ INSTALL:
stx gettype+2
gettype:jsr $0000
sta ostype
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; Fall through
; UNINSTALL routine. Is called before the driver is removed from memory.
diff --git a/libsrc/apple2/mou/a2.stdmou.s b/libsrc/apple2/mou/a2.stdmou.s
index dfc69a942..c54c09d34 100644
--- a/libsrc/apple2/mou/a2.stdmou.s
+++ b/libsrc/apple2/mou/a2.stdmou.s
@@ -133,8 +133,8 @@ next: inc ptr1+1
bcc :+
; Mouse firmware not found
- lda #MOUSE_ERR_NO_DEVICE
+ lda #MOUSE_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
; Check Pascal 1.1 Firmware Protocol ID bytes
diff --git a/libsrc/apple2/ser/a2.ssc.s b/libsrc/apple2/ser/a2.ssc.s
index d49bf3526..6ad9c3825 100644
--- a/libsrc/apple2/ser/a2.ssc.s
+++ b/libsrc/apple2/ser/a2.ssc.s
@@ -168,8 +168,9 @@ SER_CLOSE:
sta ACIA_CMD,x
; Done, return an error code
-: lda #SER_ERR_NO_DEVICE
+NoDevice:lda #SER_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
; Invalid parameter
-InvParam:lda #SER_ERR_INIT_FAILED
+InvParam:lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
-InvBaud:lda #SER_ERR_BAUD_UNAVAIL
+InvBaud:lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -292,8 +294,8 @@ SER_GET:
: lda RecvFreeCnt ; (25)
cmp #$FF
bne :+
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -336,8 +338,8 @@ SER_PUT:
; Put byte into send buffer & send
: ldy SendFreeCnt
bne :+
- lda #SER_ERR_OVERFLOW
+ lda #SER_ERR_OVERFLOW
+ ldx #0 ; return value is char
rts
: ldy SendTail
@@ -346,7 +348,8 @@ SER_PUT:
dec SendFreeCnt
lda #$FF ; TryHard = true
jsr TryToSend
- lda #SER_ERR_INV_IOCTL
+: lda #SER_ERR_INV_IOCTL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/atari/joy/atrmj8.s b/libsrc/atari/joy/atrmj8.s
index 3a26c381d..daf11651d 100644
--- a/libsrc/atari/joy/atrmj8.s
+++ b/libsrc/atari/joy/atrmj8.s
@@ -69,7 +69,8 @@ INSTALL:
lda #$34
sta PACTL
lda #JOY_ERR_OK
- ldx #0
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/atari/joy/atrstd.s b/libsrc/atari/joy/atrstd.s
index fd1d99d31..1a124192f 100644
--- a/libsrc/atari/joy/atrstd.s
+++ b/libsrc/atari/joy/atrstd.s
@@ -62,7 +62,8 @@ JOY_COUNT = 4 ; Number of joysticks we support
INSTALL:
lda #JOY_ERR_OK
- ldx #0
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/atari/mou/atrjoy.s b/libsrc/atari/mou/atrjoy.s
index 3ea428576..a93c7de13 100644
--- a/libsrc/atari/mou/atrjoy.s
+++ b/libsrc/atari/mou/atrjoy.s
@@ -137,9 +137,10 @@ INSTALL:
ldx YPos+1
jsr CMOVEY
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/atari/mou/atrst.s b/libsrc/atari/mou/atrst.s
index 5d8a5cd12..626b7a8f7 100644
--- a/libsrc/atari/mou/atrst.s
+++ b/libsrc/atari/mou/atrst.s
@@ -268,9 +268,10 @@ INSTALL:
and #$0f
sta old_porta_vbi
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/atari/mou/atrtt.s b/libsrc/atari/mou/atrtt.s
index 61963aa61..b1e53935e 100644
--- a/libsrc/atari/mou/atrtt.s
+++ b/libsrc/atari/mou/atrtt.s
@@ -132,9 +132,10 @@ INSTALL:
ldx YPos+1
jsr CMOVEY
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/atari/ser/atrrdev.s b/libsrc/atari/ser/atrrdev.s
index 3a7bc21c2..1d2b98e8d 100644
--- a/libsrc/atari/ser/atrrdev.s
+++ b/libsrc/atari/ser/atrrdev.s
@@ -135,8 +135,8 @@ my_CIOV:
.code
invbaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
openerr:
rts
@@ -229,8 +229,9 @@ SER_OPEN:
jsr my_CIOV
bmi cioerr
- lda #SER_ERR_OK
+@done: lda #SER_ERR_OK
+ .assert SER_ERR_OK = 0, error
+ tax
rts
;----------------------------------------------------------------------------
@@ -365,16 +367,16 @@ SER_GET:
rts
@nix_da:lda #SER_ERR_NO_DATA
- ldx #0
+ ldx #0 ; return value is char
rts
ser_error:
lda #SER_ERR_OVERFLOW ; there is no large selection of serial error codes... :-/
- ldx #0
+ ldx #0 ; return value is char
rts
ni_err: lda #SER_ERR_NOT_OPEN
- ldx #0
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -427,8 +429,8 @@ SER_STATUS:
;
SER_IOCTL:
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -456,8 +458,8 @@ search: lda HATABS,y ; get device name
; R: device not found, return error
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/atmos/joy/atmos-ijk.s b/libsrc/atmos/joy/atmos-ijk.s
index 6e75a3e0b..c2bdd67ab 100644
--- a/libsrc/atmos/joy/atmos-ijk.s
+++ b/libsrc/atmos/joy/atmos-ijk.s
@@ -55,11 +55,12 @@ INSTALL:
lda VIA::PRA
and #%00100000
bne ijkPresent
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/atmos/joy/atmos-pase.s b/libsrc/atmos/joy/atmos-pase.s
index fd64901c9..d9982cafe 100644
--- a/libsrc/atmos/joy/atmos-pase.s
+++ b/libsrc/atmos/joy/atmos-pase.s
@@ -58,7 +58,8 @@ temp2: .byte $00
INSTALL:
lda #JOY_ERR_OK
- ldx #0
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/atmos/ser/atmos-acia.s b/libsrc/atmos/ser/atmos-acia.s
index f84b66a0a..f679125d1 100644
--- a/libsrc/atmos/ser/atmos-acia.s
+++ b/libsrc/atmos/ser/atmos-acia.s
@@ -141,8 +141,9 @@ SER_CLOSE:
sta ACIA::CMD,x
; Done, return an error code
-: lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -277,8 +279,8 @@ SER_PUT:
; Put byte into send buffer & send
: ldy SendFreeCnt
bne :+
- lda #SER_ERR_OVERFLOW
+ lda #SER_ERR_OVERFLOW
+ ldx #0 ; return value is char
rts
: ldy SendTail
@@ -287,7 +289,8 @@ SER_PUT:
dec SendFreeCnt
lda #$FF ; TryHard = true
jsr TryToSend
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/atmos/tgi/atmos-228-200-3.s b/libsrc/atmos/tgi/atmos-228-200-3.s
index 98d2cef96..466f6922a 100644
--- a/libsrc/atmos/tgi/atmos-228-200-3.s
+++ b/libsrc/atmos/tgi/atmos-228-200-3.s
@@ -215,7 +215,8 @@ SETPALETTE:
jsr PAPER
ldy #1
jsr flipcolor
- dey ; TGI_ERR_OK
+ .assert TGI_ERR_OK = 0, error
+ dey
sty ERROR
sty PARAM1+1
jmp INK
diff --git a/libsrc/c128/emd/c128-efnram.s b/libsrc/c128/emd/c128-efnram.s
index 788c73e0f..909c90048 100644
--- a/libsrc/c128/emd/c128-efnram.s
+++ b/libsrc/c128/emd/c128-efnram.s
@@ -87,16 +87,17 @@ INSTALL:
cli
cmp tmp1
beq @ram_present
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@ram_present:
ldx #$FF
stx curpage
stx curpage+1 ; Invalidate the current page
+ .assert EM_ERR_OK = 0, error
inx
- txa ; A = X = EM_ERR_OK
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-georam.s b/libsrc/c128/emd/c128-georam.s
index 7511c6841..ecf12f6cd 100644
--- a/libsrc/c128/emd/c128-georam.s
+++ b/libsrc/c128/emd/c128-georam.s
@@ -120,16 +120,16 @@ INSTALL:
bne @setok
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@setok:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
check:
diff --git a/libsrc/c128/emd/c128-ifnram.s b/libsrc/c128/emd/c128-ifnram.s
index 01a4fdf8e..c51b775b2 100644
--- a/libsrc/c128/emd/c128-ifnram.s
+++ b/libsrc/c128/emd/c128-ifnram.s
@@ -87,16 +87,17 @@ INSTALL:
cli
cmp tmp1
beq @ram_present
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@ram_present:
ldx #$FF
stx curpage
stx curpage+1 ; Invalidate the current page
+ .assert EM_ERR_OK = 0, error
inx
- txa ; A = X = EM_ERR_OK
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-ram.s b/libsrc/c128/emd/c128-ram.s
index 3fc52c9cc..0ae504b84 100644
--- a/libsrc/c128/emd/c128-ram.s
+++ b/libsrc/c128/emd/c128-ram.s
@@ -68,8 +68,9 @@ INSTALL:
ldx #$FF
stx curpage
stx curpage+1 ; Invalidate the current page
+ .assert EM_ERR_OK = 0, error
inx
- txa ; A = X = EM_ERR_OK
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-ram2.s b/libsrc/c128/emd/c128-ram2.s
index 7d2703fa5..92e72700a 100644
--- a/libsrc/c128/emd/c128-ram2.s
+++ b/libsrc/c128/emd/c128-ram2.s
@@ -107,8 +107,9 @@ INSTALL:
ldx #$FF
stx curpage
stx curpage+1 ; Invalidate the current page
+ .assert EM_ERR_OK = 0, error
inx
- txa ; A = X = EM_ERR_OK
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-ramcart.s b/libsrc/c128/emd/c128-ramcart.s
index e72d053ac..c58c1cd1b 100644
--- a/libsrc/c128/emd/c128-ramcart.s
+++ b/libsrc/c128/emd/c128-ramcart.s
@@ -97,13 +97,14 @@ INSTALL:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@notpresent:
@readonly:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-reu.s b/libsrc/c128/emd/c128-reu.s
index 84e7cb695..8228a0517 100644
--- a/libsrc/c128/emd/c128-reu.s
+++ b/libsrc/c128/emd/c128-reu.s
@@ -126,8 +126,9 @@ size_found:
pagecount_ok:
stx pagecount
sty pagecount+1
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
; common REU setup for size check
diff --git a/libsrc/c128/emd/c128-vdc.s b/libsrc/c128/emd/c128-vdc.s
index accb82154..8d0b77fd2 100644
--- a/libsrc/c128/emd/c128-vdc.s
+++ b/libsrc/c128/emd/c128-vdc.s
@@ -121,8 +121,9 @@ INSTALL:
lda vdc_cset_save
jsr vdcputreg
@keep64kBit:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
test64k:
diff --git a/libsrc/c128/joy/c128-ptvjoy.s b/libsrc/c128/joy/c128-ptvjoy.s
index 180f7667d..0a1c53587 100644
--- a/libsrc/c128/joy/c128-ptvjoy.s
+++ b/libsrc/c128/joy/c128-ptvjoy.s
@@ -53,8 +53,9 @@ JOY_COUNT = 4 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/joy/c128-stdjoy.s b/libsrc/c128/joy/c128-stdjoy.s
index bf2e2fea7..ee04374ee 100644
--- a/libsrc/c128/joy/c128-stdjoy.s
+++ b/libsrc/c128/joy/c128-stdjoy.s
@@ -57,8 +57,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/mou/c128-1351.s b/libsrc/c128/mou/c128-1351.s
index 79ccbe0de..76e28d9f7 100644
--- a/libsrc/c128/mou/c128-1351.s
+++ b/libsrc/c128/mou/c128-1351.s
@@ -194,9 +194,10 @@ INSTALL:
sta (ptr3),y
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/c128/mou/c128-inkwell.s b/libsrc/c128/mou/c128-inkwell.s
index b8e71bbb1..2aac7d32d 100644
--- a/libsrc/c128/mou/c128-inkwell.s
+++ b/libsrc/c128/mou/c128-inkwell.s
@@ -228,9 +228,10 @@ INSTALL:
jsr MoveX
cli
-; Done, return zero.
+; Done
lda #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
tax
rts
diff --git a/libsrc/c128/mou/c128-joy.s b/libsrc/c128/mou/c128-joy.s
index 065674dc0..d809db526 100644
--- a/libsrc/c128/mou/c128-joy.s
+++ b/libsrc/c128/mou/c128-joy.s
@@ -195,9 +195,10 @@ INSTALL:
sta (ptr3),y
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/c128/mou/c128-pot.s b/libsrc/c128/mou/c128-pot.s
index e582d64fb..1cbe4aa18 100644
--- a/libsrc/c128/mou/c128-pot.s
+++ b/libsrc/c128/mou/c128-pot.s
@@ -195,9 +195,10 @@ INSTALL:
sta (ptr3),y
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/c128/ser/c128-swlink.s b/libsrc/c128/ser/c128-swlink.s
index 3337e2668..7d36eb5bc 100644
--- a/libsrc/c128/ser/c128-swlink.s
+++ b/libsrc/c128/ser/c128-swlink.s
@@ -187,8 +187,9 @@ SetNMI: sta NMIVec
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -300,8 +302,9 @@ SER_CLOSE:
; Return OK
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -370,7 +373,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c16/emd/c16-ram.s b/libsrc/c16/emd/c16-ram.s
index a8083aca4..937019974 100644
--- a/libsrc/c16/emd/c16-ram.s
+++ b/libsrc/c16/emd/c16-ram.s
@@ -77,12 +77,13 @@ INSTALL:
ldx #$FF
stx curpage ; Invalidate the current page
- inx ; X = 0
- txa ; A = X = EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ inx
+ txa
rts
-nomem: ldx #>EM_ERR_NO_DEVICE
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@not_present:
cli
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/emd/c64-c256k.s b/libsrc/c64/emd/c64-c256k.s
index 79706e8fb..5a4bc54c3 100644
--- a/libsrc/c64/emd/c64-c256k.s
+++ b/libsrc/c64/emd/c64-c256k.s
@@ -158,13 +158,14 @@ INSTALL:
jsr restore_data
cpy #$01
beq @present
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@present:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-dqbb.s b/libsrc/c64/emd/c64-dqbb.s
index 986c5939d..6a63b3baa 100644
--- a/libsrc/c64/emd/c64-dqbb.s
+++ b/libsrc/c64/emd/c64-dqbb.s
@@ -147,13 +147,14 @@ INSTALL:
jsr restore_data
cpy #$01
beq @present
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@present:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-georam.s b/libsrc/c64/emd/c64-georam.s
index 97f1a7cc4..0116fe8ea 100644
--- a/libsrc/c64/emd/c64-georam.s
+++ b/libsrc/c64/emd/c64-georam.s
@@ -121,16 +121,17 @@ INSTALL:
bne @setok
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@setok:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
check:
diff --git a/libsrc/c64/emd/c64-isepic.s b/libsrc/c64/emd/c64-isepic.s
index 3764443e2..2b7949757 100644
--- a/libsrc/c64/emd/c64-isepic.s
+++ b/libsrc/c64/emd/c64-isepic.s
@@ -76,13 +76,14 @@ INSTALL:
beq @setok
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@setok:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-kerberos.s b/libsrc/c64/emd/c64-kerberos.s
index 30183362f..20be4e409 100644
--- a/libsrc/c64/emd/c64-kerberos.s
+++ b/libsrc/c64/emd/c64-kerberos.s
@@ -82,13 +82,14 @@ INSTALL:
cmp #$AA
bne @notpresent
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
; use rts from UNINSTALL below
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-ram.s b/libsrc/c64/emd/c64-ram.s
index 5355b552d..cdd7b8965 100644
--- a/libsrc/c64/emd/c64-ram.s
+++ b/libsrc/c64/emd/c64-ram.s
@@ -65,8 +65,9 @@ window: .res 256 ; Memory "window"
INSTALL:
ldx #$FF
stx curpage ; Invalidate the current page
- inx ; X = 0
- txa ; A = X = EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ inx
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-ramcart.s b/libsrc/c64/emd/c64-ramcart.s
index 8998bb6d6..a99f25b4f 100644
--- a/libsrc/c64/emd/c64-ramcart.s
+++ b/libsrc/c64/emd/c64-ramcart.s
@@ -98,13 +98,13 @@ INSTALL:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@notpresent:
@readonly:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-reu.s b/libsrc/c64/emd/c64-reu.s
index 07ac1fbed..832e66f51 100644
--- a/libsrc/c64/emd/c64-reu.s
+++ b/libsrc/c64/emd/c64-reu.s
@@ -127,8 +127,9 @@ size_found:
pagecount_ok:
stx pagecount
sty pagecount+1
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
; common REU setup for size check
@@ -152,6 +153,7 @@ reu_size_check_common:
nodevice:
lda #EM_ERR_NO_DEVICE
+ .assert EM_ERR_OK = 0, error
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-vdc.s b/libsrc/c64/emd/c64-vdc.s
index 2448f09d4..60fbccbbf 100644
--- a/libsrc/c64/emd/c64-vdc.s
+++ b/libsrc/c64/emd/c64-vdc.s
@@ -87,8 +87,8 @@ INSTALL:
bne @L0
iny
bne @L0
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+; ldx #0 ; return value is char
rts
@present:
@@ -131,8 +131,9 @@ INSTALL:
sta pagecount
stx pagecount+1
@endok:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
test64k:
diff --git a/libsrc/c64/emd/dtv-himem.s b/libsrc/c64/emd/dtv-himem.s
index 6dde874f7..4d19b19d5 100644
--- a/libsrc/c64/emd/dtv-himem.s
+++ b/libsrc/c64/emd/dtv-himem.s
@@ -93,15 +93,16 @@ INSTALL:
; DTV not found
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@present:
ldx #$FF
stx curpage+1 ; Invalidate curpage
- inx ; X = 0
- txa ; A/X = EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ inx
+ txa
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/joy/c64-hitjoy.s b/libsrc/c64/joy/c64-hitjoy.s
index 3b4a0b909..a9d454fd0 100644
--- a/libsrc/c64/joy/c64-hitjoy.s
+++ b/libsrc/c64/joy/c64-hitjoy.s
@@ -59,8 +59,9 @@ temp4: .byte 0
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/joy/c64-numpad.s b/libsrc/c64/joy/c64-numpad.s
index 0ccdc4fcd..f6839d6cf 100644
--- a/libsrc/c64/joy/c64-numpad.s
+++ b/libsrc/c64/joy/c64-numpad.s
@@ -100,12 +100,14 @@ masktable:
;
INSTALL:
- lda #JOY_ERR_OK ; Assume we have a joystick
- ldx VIC_CLK_128 ; Test for a C128
- cpx #$FF
+ lda #JOY_ERR_OK ; Assume we have a "joystick"
+ .assert JOY_ERR_OK = 0, error
+ tax ; Set high byte
+ ldy VIC_CLK_128 ; Test for a C128
+ cpy #$FF
bne @C128 ; Jump if we have one
lda #JOY_ERR_NO_DEVICE ; No C128 -> no numpad
-@C128: ldx #0 ; Set high byte
+@C128:
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/joy/c64-ptvjoy.s b/libsrc/c64/joy/c64-ptvjoy.s
index a772fb5f6..30466b2c2 100644
--- a/libsrc/c64/joy/c64-ptvjoy.s
+++ b/libsrc/c64/joy/c64-ptvjoy.s
@@ -52,8 +52,9 @@ JOY_COUNT = 4 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/joy/c64-stdjoy.s b/libsrc/c64/joy/c64-stdjoy.s
index d11093fba..511032507 100644
--- a/libsrc/c64/joy/c64-stdjoy.s
+++ b/libsrc/c64/joy/c64-stdjoy.s
@@ -56,8 +56,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/mou/c64-1351.s b/libsrc/c64/mou/c64-1351.s
index a7d042c7b..ce0f18803 100644
--- a/libsrc/c64/mou/c64-1351.s
+++ b/libsrc/c64/mou/c64-1351.s
@@ -152,9 +152,10 @@ INSTALL:
jsr CMOVEY
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -307,8 +308,8 @@ INFO: jsr POS
; Must return an error code in a/x.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/mou/c64-inkwell.s b/libsrc/c64/mou/c64-inkwell.s
index 9c876a7c8..d2f14a6f0 100644
--- a/libsrc/c64/mou/c64-inkwell.s
+++ b/libsrc/c64/mou/c64-inkwell.s
@@ -168,6 +168,7 @@ INSTALL:
; Done, return zero.
lda #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
tax
rts
@@ -319,8 +320,8 @@ INFO: jsr POS
; Must return an error code in .XA.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/mou/c64-joy.s b/libsrc/c64/mou/c64-joy.s
index f2a501000..5ee1b4f84 100644
--- a/libsrc/c64/mou/c64-joy.s
+++ b/libsrc/c64/mou/c64-joy.s
@@ -156,9 +156,10 @@ INSTALL:
jsr CMOVEY
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -312,8 +313,8 @@ INFO: jsr POS
; Must return an error code in a/x.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/mou/c64-pot.s b/libsrc/c64/mou/c64-pot.s
index 102ca351c..9bdf24f62 100644
--- a/libsrc/c64/mou/c64-pot.s
+++ b/libsrc/c64/mou/c64-pot.s
@@ -139,9 +139,10 @@ INSTALL:
jsr CMOVEY
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -297,8 +298,8 @@ INFO: jsr POS
; Must return an error code in a/x.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/ser/c64-swlink.s b/libsrc/c64/ser/c64-swlink.s
index 597cf1dd6..81c9916a6 100644
--- a/libsrc/c64/ser/c64-swlink.s
+++ b/libsrc/c64/ser/c64-swlink.s
@@ -161,8 +161,9 @@ SetNMI: sta NMIVec
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -274,8 +276,9 @@ SER_CLOSE:
; Return OK
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -344,7 +347,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/cbm510/emd/cbm510-ram.s b/libsrc/cbm510/emd/cbm510-ram.s
index f724c7360..6cc319b7f 100644
--- a/libsrc/cbm510/emd/cbm510-ram.s
+++ b/libsrc/cbm510/emd/cbm510-ram.s
@@ -81,8 +81,9 @@ INSTALL:
sbc #$00
sta pagecount
-@L1: lda #EM_ERR_OK
+@L1: lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/cbm510/joy/cbm510-std.s b/libsrc/cbm510/joy/cbm510-std.s
index 4e47fc1a0..f7cbb2cdc 100644
--- a/libsrc/cbm510/joy/cbm510-std.s
+++ b/libsrc/cbm510/joy/cbm510-std.s
@@ -57,8 +57,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/cbm510/mou/cbm510-inkwl.s b/libsrc/cbm510/mou/cbm510-inkwl.s
index 91bc52fcd..ea6d95934 100644
--- a/libsrc/cbm510/mou/cbm510-inkwl.s
+++ b/libsrc/cbm510/mou/cbm510-inkwl.s
@@ -175,6 +175,7 @@ INSTALL:
; Done, return zero.
lda #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
tax
rts
@@ -331,8 +332,8 @@ INFO: jsr POS
; Must return an error code in .XA.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/cbm510/mou/cbm510-joy.s b/libsrc/cbm510/mou/cbm510-joy.s
index 8aa3a778e..4daa49272 100644
--- a/libsrc/cbm510/mou/cbm510-joy.s
+++ b/libsrc/cbm510/mou/cbm510-joy.s
@@ -140,7 +140,8 @@ INSTALL:
; Done, return zero.
- ldx #>MOUSE_ERR_OK
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -315,8 +316,8 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
; Must return an error code in .XA.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/cbm510/ser/cbm510-std.s b/libsrc/cbm510/ser/cbm510-std.s
index 64f613cd5..cc58c1233 100644
--- a/libsrc/cbm510/ser/cbm510-std.s
+++ b/libsrc/cbm510/ser/cbm510-std.s
@@ -148,8 +148,9 @@ SER_CLOSE:
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -253,8 +255,8 @@ SER_GET:
@L1: lda RecvFreeCnt
cmp #$ff
bne @L2
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -301,7 +303,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/cbm610/emd/cbm610-ram.s b/libsrc/cbm610/emd/cbm610-ram.s
index 5c67df7a4..5aa43b0c2 100644
--- a/libsrc/cbm610/emd/cbm610-ram.s
+++ b/libsrc/cbm610/emd/cbm610-ram.s
@@ -81,8 +81,9 @@ INSTALL:
sbc #$00
sta pagecount
-@L1: lda #EM_ERR_OK
+@L1: lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/cbm610/ser/cbm610-std.s b/libsrc/cbm610/ser/cbm610-std.s
index 7cdb285bd..f7ddde935 100644
--- a/libsrc/cbm610/ser/cbm610-std.s
+++ b/libsrc/cbm610/ser/cbm610-std.s
@@ -149,8 +149,9 @@ SER_CLOSE:
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -254,8 +256,8 @@ SER_GET:
@L1: lda RecvFreeCnt
cmp #$ff
bne @L2
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -302,7 +304,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s
index 73b0c249f..43f9a2b40 100644
--- a/libsrc/creativision/joy/creativision-stdjoy.s
+++ b/libsrc/creativision/joy/creativision-stdjoy.s
@@ -59,7 +59,8 @@ JOY_RIGHT = $08
;
INSTALL: lda #JOY_ERR_OK
- ldx #>$0000
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Fall through
; ------------------------------------------------------------------------
diff --git a/libsrc/cx16/joy/cx16-std.s b/libsrc/cx16/joy/cx16-std.s
index a40fcb061..5def55511 100644
--- a/libsrc/cx16/joy/cx16-std.s
+++ b/libsrc/cx16/joy/cx16-std.s
@@ -55,8 +55,9 @@ JOY_COUNT = $05 ; Number of joysticks we support
; Must return a JOY_ERR_xx code in .XA .
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/cx16/mou/cx16-std.s b/libsrc/cx16/mou/cx16-std.s
index 3af7d2eb3..f211815de 100644
--- a/libsrc/cx16/mou/cx16-std.s
+++ b/libsrc/cx16/mou/cx16-std.s
@@ -139,7 +139,8 @@ INSTALL:
; Done, return zero
- ldx #>MOUSE_ERR_OK
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -300,8 +301,8 @@ INFO: jsr BUTTONS ; Will not touch ptr1
; specific data in ptr1, and the ioctl code in A.
; Must return an error code in .XA .
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
+ ldx #0 ; return value is char
; rts ; Fall through
;----------------------------------------------------------------------------
diff --git a/libsrc/gamate/joy/gamate-stdjoy.s b/libsrc/gamate/joy/gamate-stdjoy.s
index 8f927cdf5..514f92db4 100644
--- a/libsrc/gamate/joy/gamate-stdjoy.s
+++ b/libsrc/gamate/joy/gamate-stdjoy.s
@@ -47,8 +47,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/geos-cbm/emd/geos-vdc.s b/libsrc/geos-cbm/emd/geos-vdc.s
index 27316e1a0..2e7d19c03 100644
--- a/libsrc/geos-cbm/emd/geos-vdc.s
+++ b/libsrc/geos-cbm/emd/geos-vdc.s
@@ -125,8 +125,9 @@ INSTALL:
pla
sta $01
plp
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
test64k:
diff --git a/libsrc/geos-cbm/joy/geos-stdjoy.s b/libsrc/geos-cbm/joy/geos-stdjoy.s
index 2787cb594..a3fd4ffc8 100644
--- a/libsrc/geos-cbm/joy/geos-stdjoy.s
+++ b/libsrc/geos-cbm/joy/geos-stdjoy.s
@@ -53,8 +53,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/joystick/joy_unload.s b/libsrc/joystick/joy_unload.s
index 25d54ff02..f52b7a2c1 100644
--- a/libsrc/joystick/joy_unload.s
+++ b/libsrc/joystick/joy_unload.s
@@ -10,7 +10,7 @@
.include "modload.inc"
.import joy_clear_ptr
- .import return0
+ .import return0, return1
@@ -31,7 +31,6 @@ _joy_unload:
jmp return0 ; Return JOY_ERR_OK
no_driver:
- tax ; X = 0
pla ; Remove pushed junk
- lda #JOY_ERR_NO_DRIVER
- rts
+ .assert JOY_ERR_NO_DRIVER = 1, error
+ jmp return1 ; Return JOY_ERR_NO_DRIVER
diff --git a/libsrc/lynx/joy/lynx-stdjoy.s b/libsrc/lynx/joy/lynx-stdjoy.s
index c81a97dbf..45eb8ab4e 100644
--- a/libsrc/lynx/joy/lynx-stdjoy.s
+++ b/libsrc/lynx/joy/lynx-stdjoy.s
@@ -58,8 +58,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/lynx/ser/lynx-comlynx.s b/libsrc/lynx/ser/lynx-comlynx.s
index ded862eaa..8aa3c838e 100644
--- a/libsrc/lynx/ser/lynx-comlynx.s
+++ b/libsrc/lynx/ser/lynx-comlynx.s
@@ -75,8 +75,9 @@ SER_UNINSTALL:
SER_CLOSE:
; Disable interrupts
; Done, return an error code
- lda #SER_ERR_OK
+ lda #SER_ERR_OK
+ .assert SER_ERR_OK = 0, error
+ tax
rts
;----------------------------------------------------------------------------
@@ -190,8 +191,8 @@ SER_OPEN:
cmp #SER_BAUD_134_5
beq setbaudrate
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
setprescaler:
stx TIM4CTLA
@@ -238,12 +239,13 @@ checkhs:
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
- lda #SER_ERR_OK
+ lda #SER_ERR_OK
+ .assert SER_ERR_OK = 0, error
+ tax
rts
invparameter:
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -255,8 +257,8 @@ SER_GET:
lda RxPtrIn
cmp RxPtrOut
bne GetByte
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
GetByte:
ldy RxPtrOut
@@ -277,8 +279,8 @@ SER_PUT:
ina
cmp TxPtrOut
bne PutByte
- lda #SER_ERR_OVERFLOW
+ lda #SER_ERR_OVERFLOW
+ ldx #0 ; return value is char
rts
PutByte:
ldy TxPtrIn
@@ -296,7 +298,8 @@ PutByte:
sta TxDone
plp
@L1:
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/mouse/mouse_unload.s b/libsrc/mouse/mouse_unload.s
index 8c9018484..ecd7846ab 100644
--- a/libsrc/mouse/mouse_unload.s
+++ b/libsrc/mouse/mouse_unload.s
@@ -8,7 +8,7 @@
.include "mouse-kernel.inc"
.include "modload.inc"
- .import return0
+ .import return0, return1
@@ -29,7 +29,6 @@ _mouse_unload:
jmp return0 ; Return MOUSE_ERR_OK
no_driver:
- tax ; X = 0
pla ; Remove pushed junk
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/pet/joy/pet-ptvjoy.s b/libsrc/pet/joy/pet-ptvjoy.s
index c098072fb..ee14c95c8 100644
--- a/libsrc/pet/joy/pet-ptvjoy.s
+++ b/libsrc/pet/joy/pet-ptvjoy.s
@@ -51,8 +51,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/plus4/joy/plus4-stdjoy.s b/libsrc/plus4/joy/plus4-stdjoy.s
index e8e85fedc..86f080dae 100644
--- a/libsrc/plus4/joy/plus4-stdjoy.s
+++ b/libsrc/plus4/joy/plus4-stdjoy.s
@@ -58,8 +58,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/plus4/ser/plus4-stdser.s b/libsrc/plus4/ser/plus4-stdser.s
index bb44a4cf9..fbdc61b2e 100644
--- a/libsrc/plus4/ser/plus4-stdser.s
+++ b/libsrc/plus4/ser/plus4-stdser.s
@@ -157,8 +157,9 @@ SER_CLOSE:
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -261,8 +263,8 @@ SER_GET:
@L1: lda RecvFreeCnt ; (25)
cmp #$ff
bne @L2
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -309,7 +311,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts ; Run into IRQ instead
;----------------------------------------------------------------------------
diff --git a/libsrc/serial/ser_unload.s b/libsrc/serial/ser_unload.s
index bf7201255..7cd0f7125 100644
--- a/libsrc/serial/ser_unload.s
+++ b/libsrc/serial/ser_unload.s
@@ -10,7 +10,7 @@
.include "modload.inc"
.import ser_clear_ptr
- .import return0
+ .import return0, return1
@@ -28,10 +28,10 @@ _ser_unload:
tax
pla ; Get pointer to driver
jsr _mod_free ; Free the driver
- jmp return0 ; Return SER_ERR_OK
+ .assert SER_ERR_OK = 0, error
+ jmp return0
no_driver:
- tax ; X = 0
pla ; Remove pushed junk
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/telestrat/joy/telestrat.s b/libsrc/telestrat/joy/telestrat.s
index 0f5d28651..7472ab187 100644
--- a/libsrc/telestrat/joy/telestrat.s
+++ b/libsrc/telestrat/joy/telestrat.s
@@ -54,8 +54,9 @@ INSTALL:
sta VIA2::PRB
; We could detect joysticks because with previous command bit0,1,2,3,4 should be set to 1 after
; But if some one press fire or press direction, we could reach others values which could break joystick detection.
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/vic20/emd/vic20-georam.s b/libsrc/vic20/emd/vic20-georam.s
index a960e9a1a..4e3121c05 100644
--- a/libsrc/vic20/emd/vic20-georam.s
+++ b/libsrc/vic20/emd/vic20-georam.s
@@ -119,16 +119,16 @@ INSTALL:
bne @setok
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@setok:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
check:
diff --git a/libsrc/vic20/emd/vic20-rama.s b/libsrc/vic20/emd/vic20-rama.s
index 133c3974b..4264e2caf 100644
--- a/libsrc/vic20/emd/vic20-rama.s
+++ b/libsrc/vic20/emd/vic20-rama.s
@@ -71,12 +71,13 @@ INSTALL:
ldx #$FF
stx curpage ; Invalidate the current page
- inx ; X = 0
- txa ; A = X = EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ inx
+ txa
rts
-nomem: ldx #>EM_ERR_NO_DEVICE
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/vic20/joy/vic20-stdjoy.s b/libsrc/vic20/joy/vic20-stdjoy.s
index ee8dc93d7..b3de8766c 100644
--- a/libsrc/vic20/joy/vic20-stdjoy.s
+++ b/libsrc/vic20/joy/vic20-stdjoy.s
@@ -57,8 +57,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------