Skip to content

Commit

Permalink
Merge pull request #457 from paulscottrobson/case
Browse files Browse the repository at this point in the history
Case conversion added to BASIC
  • Loading branch information
paulscottrobson authored Apr 15, 2024
2 parents 40f274e + 34a2702 commit 7d1be44
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 20 deletions.
4 changes: 2 additions & 2 deletions basic/scripts/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def create(self):
self.add(0x2E0,"""
SIN( COS( TAN( ATAN( LOG( EXP( VAL( STR$(
ISVAL( SQR( PAGE SPRITEX( SPRITEY( NOTES( HIMEM VBLANKS(
ERR ERL PIN( IREAD( ANALOG( JOYCOUNT( !!UN3
IDEVICE( SPC( TAB( UHASDATA( MOS( HAVEMOUSE(
ERR ERL PIN( IREAD( ANALOG( JOYCOUNT( UPPER$(
IDEVICE( SPC( TAB( UHASDATA( MOS( HAVEMOUSE( LOWER$(
""")

if __name__ == "__main__":
Expand Down
80 changes: 80 additions & 0 deletions basic/sources/arithmetic/unary/base/upperlower.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
; ************************************************************************************************
; ************************************************************************************************
;
; Name: upperlower.asm
; Purpose: Convert string to upper/lower case
; Created: 15th April 2024
; Reviewed: No
; Author: Paul Robson ([email protected])
;
; ************************************************************************************************
; ************************************************************************************************

.section code

; ************************************************************************************************
;
; UPPER$() and LOWER$() function
;
; ************************************************************************************************

UnaryUpper: ;; [upper$(]
clc
bra CaseConversion
UnaryLower: ;; [lower$(]
sec
CaseConversion:
php ; carry flag set lower, clear upper.
jsr EXPEvalString ; string to zTemp0
jsr ERRCheckRParen

lda (zTemp0) ; allocate space for whole string
jsr StringTempAllocate

plp ; save position, put the conversion flag on TOS though
phy
php
ldy #0 ; start of string pre decrement
_CCLoop:
cmp (zTemp0) ; exit if reached length.
beq _CCDone
iny ; increment as length prefixed.

lda (zTemp0),y ; first make it upper case anyway.
cmp #"a"
bcc _CCNotLower
cmp #"z"+1
bcs _CCNotLower
eor #$20
_CCNotLower:
plp ; test flag.
php
bcc _CCOutput ; if going to upper, already done.

cmp #"A" ; test if upper case
bcc _CCOutput
cmp #"Z"+1
bcs _CCOutput
eor #$20 ; if so make lower case.

_CCOutput:
jsr StringTempWrite ; write to string.
bra _CCLoop

_CCDone:
ply ; throw conversion flag.
ply ; restore Y and exit
rts

.send code

; ************************************************************************************************
;
; Changes and Updates
;
; ************************************************************************************************
;
; Date Notes
; ==== =====
;
; ************************************************************************************************
Binary file added basic/storage/eliza.bas
Binary file not shown.
Binary file added basic/storage/robotron.bin
Binary file not shown.
Binary file added basic/storage/robotron.gfx
Binary file not shown.
21 changes: 3 additions & 18 deletions basic/test.bsc
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
'
' BASIC Mouse cursor manipulation
'
mouse show
mouse cursor 2
cls:line 0,0 ink 3 to 100,100
mouse to 260,180
repeat
b = mouse(x,y,s)
print chr$(20);x;" ";y;" ";b;" ";s;" "
until false
end
'
proc send.message(g,f)
while peek($FF00):wend
poke $FF01,f:poke $FF00,g
while peek($FF00):wend
endproc
a$ = "Hello world"
print "[";upper$(a$);"]"
print "[";lower$(a$);"]"
Binary file modified documents/release/basic.odt
Binary file not shown.
Binary file modified documents/release/basic.pdf
Binary file not shown.

0 comments on commit 7d1be44

Please sign in to comment.