0 Members and 1 Guest are viewing this topic.
Input "X: ",X
menu: LD HL,$0000 LD (curRow),HL LD HL,menuA set textInverse,(IY+textFlags) call putC res textInverse,(IY+textFlags) LD HL,$0201 push HL LD B,9menuLoop: pop HL push BC LD a,$06 LD b,H add a,b LD H,a pop BC push HL LD (penCol),HL ld de,menuA ld A,10 sub b ld H,0 LD L,A add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl add hl,de call vPutMap djnz menuLoopvPutMap: ld a,(hl) inc hl or a; ret z bcall(_VPutMap) jr vPutMap putC: ld a,(hl) inc hl or a; ret z bcall(_PutC) jr putCmenuA: .db " TITLE ",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .db "1. Item A ",0,0,0,0,0,0,0,0 .db "2. Item A ",0,0,0,0,0,0,0,0 .db "3. Item A ",0,0,0,0,0,0,0,0 .db "4. Item A ",0,0,0,0,0,0,0,0 .db "5. Item A ",0,0,0,0,0,0,0,0 .db "6. Item A ",0,0,0,0,0,0,0,0 .db "7. Item A ",0,0,0,0,0,0,0,0 .db "8. Item A ",0,0,0,0,0,0,0,0 .db "9. EXIT ",0,0,0,0,0,0,0,0
pop HL push BC LD a,$06 LD b,H add a,b LD H,a pop BC push HL LD (penCol),HL
ld a,(penCol) add a,6 ld (penCol),a
putCLoop: ld a,(hl) inc hl inc a ;$FF+1=0 ret z dec a ;0+1=1, -1=0 jr nz,$+15 ;2 ld (penCol),a ;5 ld a,(penRow) ;8 add a,6 ;10 ld (penRow),a ;13 ld a,(hl) ;14 inc hl ;15 bytes bcall(_vPutMap) jr putCLoop
;#####################################;Type name;output: HL = pointer to input string; carry = user quitbufSize equ 10 ;this is how long you want the buffer to bebuffer equ saveSScreen ;put this wherever you wanttypeName: bcall(_clrTxtShd) ;if you don't do this, letters will appear under the cursor ei set curAble, (iy + curFlags) ;we'll use the OS's cursor since it's easier ld de, buffer ;de is going to be the pointer ld b, 0 ;b will be how many characters have been entered ld hl, 0*256+0 ;this is going to start at (0,0), change this to whatever you want ld (curRow), hltypeLoop: halt ;putting a halt in this loop decreases battery use by like 90% bcall(_GetCSC) ;this gets whatever key was press (physical key, no 2nd crap) or a ;was a key pressed jr z, typeLoop ;no go back around cp skEnter ;sk[Key pressed] because we're using getCSC jr nz, notaEnter ld a, b or a jr z, notAEnter ;0 length input is silly xor a ld (de), a ;null terminator turns this into a string, you don't have to do this call curOff res curAble, (iy + curFlags) ;kill the cursor ld hl, buffer ;might as well return a pointer or a ;this resets the carry flag, carry means user quit retnotaEnter: cp skDel jr z, delTa cp skLeft ;since we're not the OS, pressing left is going to delete a number jr nz, notBackSpacedelTa: ld a, b or a jr z, typeLoop ;don't do it if there's nothing there call curOff ;prevent hanging cursor ld hl, curCol ;move the cursor back dec (hl) dec de ;move the pointer back dec b ;decrease the number of letters ld a, ' ' bcall(_PutMap) ;put a blank without moving the cursor call cursorOn jr typeLoopnotBackSpace: cp skClear jr nz, notClearz ;I have clear quitting, you can do other stuff if you want call curOff res curAble, (iy + curFlags) scf ;this lets the calling routine know you quit ret notClearz: ld c, a ld a, b cp bufSize jr z, typeLoop ;if it's too big, accept no more input ld a, c sub skChs ;this is the neg button, it's the lowest value key we want (sk value) jr c, typeLoop ;if it's under skChs ($11) we don't want the key cp skComma-skChs+1 ;skComma ($25) is the highest value we will accept jr nc, typeLoop ld hl, charTable add a, l ;this little section is HL + A ld l, a jr nc, $+3 ;after this, HL holds a pointer the the character we need to display inc h;$$ ;this is just a comment for clarity on the jump, could have used a label call curOff ;destroys A not HL (this is an actual comment from this code :D ) ld a, (hl) or a jr z, justKidding ;the button pressed was in the correct range, it just wasn't a key we wanted ld (de), a ;add it to the buffer inc de ;increase the buffer pointer inc b ;increase the counter for the bufer bcall(_PutC) ;type the character and increase (curCol) call cursorOn jp typeLoopjustKidding: call cursorOn jp typeLoopcursorOn: res curOn, (iy + curFlags) jr readykcurOff: set curOn, (iy + curFlags)readyk: ld a, 1 ;this is a clever little hack, you set the wrong cursor state ld (curTime), a ;set the curTime to 1, and let an interrupt occur ei ;since the OS decreases curTime by one every interrupt, it will halt ;reach zero and the OS will flip the cursor over to the correct state retcharTable: ;these are the letters as they appear in order of scan code .db $1A, "369", 0, 0, 0, 0 ;1A is neg .db ".258", 0, 0, 0, 0 .db "0147", $1B ;1B is E
menu: LD HL,$0000 LD (curRow),HL LD HL,menuA set textInverse,(IY+textFlags) bcall(_putS) res textInverse,(IY+textFlags) LD de,$0207 ld (penCol),de LD B,9menuLoop: ld a,(penRow) ;like chickendude said add a,6 ;but this didn't cause the slowness ld (penRow),a ld a, 2 ld (penCol), a bcall(_vPutS) djnz menuLoop bcall(_getKey) ;delay retmenuA: .db " TITLE ",0 .db "1. Item A",0 .db "2. Item A",0 .db "3. Item A",0 .db "4. Item A",0 .db "5. Item A",0 .db "6. Item A",0 .db "7. Item A",0 .db "8. Item A",0 .db "9. EXIT",0