[Coco] Simple data entry form project
William Mikrut
wmikrut72 at gmail.com
Fri Feb 24 19:48:32 EST 2017
So I have started on another project, one designed to get me used to other
parts of the system.
This particular project is a data entry form.
This program doesn't do much other than let you -- enter data.
Eventually I'll throw it out to disk -- but that's a project for another
day :)
I wanted to learn how to move from line to line, monitor for end of field,
set the cursor position AND use stack space for temp vars.
If anyone is up to the challenge, have a look and let me know what things I
could do better!
Thank you!
-------------- next part --------------
ORG $1200
;*********************************************************
;* Relocate the stack - don't mess with Basic
;*********************************************************
START LDX #STACK+200 ;*************************
STS OLDSTK ;* Thank you Robert Gault
LDS #STACK ;*************************
;*************************************************
;Use Stack space for temp vars
;*************************************************
LDD #$0000
PSHS A ;+4 = Current line
PSHS D ;+2 = End of line position
PSHS D ;+0= Start of line position
JSR $A928 ;Clear the Screen
LDX #FSCR1 ;Load the Screen
JSR PRTL.00
MAIN.00 LDA 4,S ;Get the current line
MAIN.10 LSLA ;Multiple by 2 for offset
LDU #FCPOS ;Get Start line positions
LDX A,U ;Get the current line start position
LEAU 20,X ;Calculate the max line length (20 Chars)
STX ,S ;Store Line Start
STU 2,S ;Store Line End
MAIN.11 LDA ,-U ;**************************************
CMPA #$60 ; Scan backwards on each line so we
BNE MAIN.12 ; automatically position the cursor
CMPU ,S ; just after the last character on
BNE MAIN.11 ; the line.
MAIN.12 LEAX +1,U ;**************************************
MAIN.20 STX CURPOS ;Set the cursor position
JSR $A199 ;Position the cursor
JSR $A1B1 ;Blink the cursor and wait for a key
CMPA #4 ;F2=Quit
BEQ ENDPGM
CMPA #13 ;Advance line if <ENTER> is pressed
BEQ KDWN.00
CMPA #10 ;Advance line if Down Arrow is pressed
BEQ KDWN.00
CMPA #94 ;Go back if the Up Arrow is pressed
BEQ KUP.00
CMPA #8 ;Process the backspace
BEQ KBK.00
CMPA #33 ;**************************************
BLT MAIN.21 ;Shift lower chase characters to
CMPA #63 ;upper case equivalent
BGT MAIN.21 ;
ADDA #64 ;**************************************
MAIN.21 CMPA #$20
BNE MAIN.25
LDA #$60
MAIN.25 LDX CURPOS ;Get current cursor position
STA ,X+ ;Display character and move cursor
CMPX 2,S ;Are we at the end of the line?
BLE MAIN.20 ;If not, move the cursor foward and continue
BRA MAIN.00 ;Respoition the cursor to the start of line
ENDPGM LDS OLDSTK ;Restore the stack
RTS ;Bye!
;*********************************************************
;* Print out the screen
;*********************************************************
PRTL.00 LDA ,X+
TSTA
BEQ PRTL.99
JSR [$A002]
BRA PRTL.00
PRTL.99 RTS
;*********************************************************
;* Handle back space
;*********************************************************
KBK.00 LDX CURPOS
LEAU -1,X
TFR U,X
CMPX ,S
BGT MAIN.20
LDX 2,S
JMP MAIN.20
;*********************************************************
;* Handle down arrow/Enter Key
;*********************************************************
KDWN.00 LDA 4,S
INCA
CMPA #9
BNE KDWN.01
CLRA
KDWN.01 STA 4,S
JMP MAIN.00
;*********************************************************
;* Handle up arrow
;*********************************************************
KUP.00 LDA 4,S
DECA
BPL KUP.01
LDA #8
KUP.01 STA 4,S
JMP MAIN.00
CURPOS EQU $0088
OLDSTK RMB 2 ;**************************************
RMB 200 ;Save the stack before starting
STACK EQU * ;**************************************
;*********************************************************
;* The cursor start positions for each line
;*********************************************************
FCPOS FDB #$040B,#$042B,#$044B,#$046B,#$048B,#$04AB,#$04CB,#$04EB,#$050B
;*********************************************************
;* Screen Layout
;*********************************************************
FSCR1 FCC 'FIRST NAME:'
FCB #13
FCC ' LAST NAME:'
FCB #13
FCC ' ADDRESS 1:'
FCB #13
FCC ' ADDRESS 2:'
FCB #13
FCC ' ADDRESS 3:'
FCB #13
FCC ' CITY:'
FCB #13
FCC ' STATE:'
FCB #13
FCC ' ZIP CODE:'
FCB #13
FCC ' PHONE:'
FCB #13,#13,#13,#13,#13,#13,#13
FCC 'F2=EXIT'
FCB 0
END START
More information about the Coco
mailing list