; Lingo ; A wordguess game with 242 words in just 1K nrwords equ 242 final equ #3D ; letter "X", no words with XYZ org #4009 inmem equ #4000 ; in LOWRES more sysvar are used, but in this way the shortest code ; over sysvar to start machinecode. This saves 11 bytes of BASIC ; DO NOT CHANGE AFTER BASIC+3 (=DFILE) basic ld h,dfile/256 ; highbyte of dfile jr init1 db 236 ; BASIC over DFILE data db 212,28 db 126,143,0,18 eline dw last chadd dw last-1 db 0,0,0,0,0,0 ; x berg db 0 ; x mem db 0,0 ; x OVERWRITTEN ON LOAD init1 ld l, dfile mod 256 ; low byte of dfile jr init2 lastk db 255,255,255 margin db 55 nxtlin dw basic ; BASIC-line over sysvar flagx equ init2+2 init2 ld (basic+3),hl ; repair correct DFILE flagx will be set with 64, the correct value db 0,0,0 ; x used by ZX81, not effective code after loading db 0,0,33 ; skip frames with LD HL,NN frames dw 65535 jp game ; YOUR ACTUAL GAMECODE, can be everywhere wrdcnt db nrwords+1 db 0 cdflag db 64 ; DO NOT CHANGE SYSVAR ABOVE! ; free codeable memory game ld de,#640a ; routine to enter a number D=100, E=10 ld c,0 ; numberresult ld hl,screen ; a place on the screen rten push de ; save counters call readkey ; read a key pop de ld (hl),a ; write to screen inc hl sub 28 ; make it number only ld b,a jr z,noadd ; skip when 0 entered ld a,c add1 add a,d djnz add1 ; add HUNDERDs or add TENs ld c,a noadd ld a,d cp e ld d,e jr nz,rten ; double loop call readkey ; read third input ld (hl),a sub 27 add a,c ld (readcnt+1),a ; the levels to skip ld c,38 ; First letter of a word, start with "A" wcnt ld hl,wrdcnt dec (hl) flash ld hl,count+3 jr nz,one ; still words left ld b,3 ; flashing celibrations on end of game setend dec hl ld a,(hl) xor 128 ld (hl),a dec b jr nz,setend jr flash ten ld (hl),28 one dec hl inc (hl) ; show next wordcount on screen ld a,(hl) cp 38 jr z,ten rseed ld hl,0 ; use ROM to read in fixed order ld b,(hl) inc hl ld (rseed+1),hl nword ld hl,stword-2 ; start of next word call fword ; find start of your word inc b call testnxt ; test if unused or next startletter ld (nword+1),hl ; now we have a word, start next here ld a,c exx ld hl,inmem ld (hl),a ; first letter written exx call dwrite ; write 2 letters from (hl) inc (hl) ; signal word is used inc hl call dwrite ; write 2 letters from (hl) readcnt ld a,7 ; skip a number of words dec a jr z,w4sp-1 ld (readcnt+1),a wcrel jr wcnt exx w4sp ld a,(lastk) cp 127 jr nz,w4sp ; start next word with space cls ld hl,screen ; erase a previous screen clscr ld a,(hl) cp 118 jr z,skinl ld (hl),0 skinl inc hl ld a,l cp eos mod 256 jr nz,clscr ld bc,screen-2 inplp inc bc push bc stinp ld hl,input reread call readkey cp 118 jr z,nline ; test on Newline cp #40 jr nc,reread ; test not visible code which i false input ld (hl),a ; write on screen inc hl ld a,(hl) cp 118 jr z,stinp ; input cursor in front jr stinp+3 ; read next input ; analyse the word, copy when right nline pop bc res 7,(hl) ; undo last set cursor ld de,input ld hl,inmem ; the location of the unpacked word npos ld a,(de) ; get inputletter cp (hl) ; test against letter in word jr z,setok ; if ok, show it inverted push hl ; save memorylocation push bc ; save screenlocation ld l,inmem mod 256 ; point again to start of guessword ld b,5 ; test 5 letters chall cp (hl) ; test on different position inc hl jr z,setused ; match, letter is in word djnz chall ; test all letters setused pop bc ; get screen pop hl ; get wordposition jr z,nlet ; used, not ok pos ld a,22+128 ; not in word, inverted "-" setok xor 128 ; invert current character nlet inc bc ; point to show position ld (bc),a ; signal lettervalue on pos inc hl ; next letter of guessword inc de ; next letter of input ld a,(de) cp 118 jr nz,npos ; test end of input reached push bc ; save screenposition ld h,b ld l,c ld bc,#505 ; 5 letterword, 5 letters false f5 ld a,(hl) dec hl add a,a jr nc,skipdec dec c ; 1 letter less false skipdec djnz f5 pop bc ld a,c exx jr z,wcrel ; all letters are highlighted, word guessed, JR in 2 steps for size exx cp lword mod 256 ; test last word inputted jr c,inplp ; not on end of screen jp w4sp ; same word new input nonext and #f0 ; test bit 4-7, word is already used jr z,fword dec b ret z ; word found fword inc hl ; skip letters current word inc hl testnxt ld a,(hl) ; get word valid code or a ; test next leadletter jr nz,nonext inc c ; next startletter ld a,c cp final ; test against last letter in alfabet jr c,testnxt-1 ; find a word ld hl,stword ; search from start ld c,38 ; first letter jr testnxt dwrite call write ; write first letter in (hl) write xor a ; also write second rld ; get letter exx inc hl ; next position on screen ld de,letters-1 ; the used letters in the alfabet add a,e ld e,a ld a,(de) ; asciicode of letter ld (hl),a ; write letter exx ret readkey set 7,(hl) ; show cursor push bc wup inc a ; test keyup w4othr ld bc,(lastk) ld a,c jr nz,wup inc a ; test keydown jr z,w4othr push hl call #7bd ld hl,#7d add a,l ld l,a ld a,(hl) ; get ascii code pressed key pop hl pop bc ret letters db #26,#27,#28,#29,#2A,#2B ; abcdef db #2E,#31,#32,#33,#34,#35 ; ilmnop db #37,#38,#39 ; rst stword db #3f,#bd ;Actor db #41,#cf ;Adapt db #49,#7f ;Admit db #6f,#5d ;After db #7d,#54 ;Aired db #85,#df ;Alert db #87,#5a ;Alien db #8b,#a5 ;Alone db #8f,#5d ;Alter db #92,#5d ;Amber db #ab,#45 ;Anode db #d5,#1e ;Areas db #d5,#a1 ;Arena db #db,#e5 ;Arose db #de,#ba ;Arson db #e7,#45 ;Aside db #f8,#1e ;Atlas db #45,#cf,0 ;Adept db #1e,#54 ;Based db #51,#d4 ;Beard db #51,#de ;Bears db #51,#ef ;Beast db #58,#fe ;Belts db #7d,#4e ;Birds db #81,#45 ;Blade db #81,#95 ;Blame db #81,#ef ;Blast db #d5,#14 ;Bread db #d7,#25 ;Bribe db #d7,#45,0 ;Bride db #1a,#b5 ;Canoe db #1d,#4e ;Cards db #81,#ec ;Clasp db #81,#ee ;Class db #1a,#5e ;Canes db #1e,#54 ;Cased db #d5,#4b ;Credo db #8b,#e5 ;Close db #b1,#8e ;Coals db #b1,#ef ;Coast db #b4,#5d ;Coder db #b7,#8e ;Coils db #ba,#5e ;Cones db #d1,#a5 ;Crane db #d5,#19 ;Cream db #d5,#ef ;Crest db #d7,#ec,0 ;Crisp db #1d,#5e ;Dares db #1d,#fe ;Darts db #1f,#5e ;Dates db #51,#8e ;Deals db #59,#ba ;Demon db #73,#5e ;Dices db #75,#fe ;Diets db #7a,#5d ;Diner db #d1,#6f ;Draft db #d5,#14 ;Dread db #d7,#6f ;Drift db #db,#a5,0 ;Drone db #af,#5d ;Enter db #d1,#e5 ;Erase db #d5,#3f,0 ;Erect db #13,#5e ;Faces db #13,#fe ;Facts db #17,#af ;Faint db #1d,#9e ;Farms db #1f,#5e ;Fates db #51,#de ;Fears db #51,#ef ;Feast db #7a,#18 ;Final db #7d,#54 ;Fired db #81,#95 ;Flame db #b3,#18 ;Focal db #d1,#95 ;Frame db #17,#8e,0 ;Fails db #17,#ae ;Gains db #19,#5d ;Gamer db #19,#91 ;Gamma db #1f,#5e ;Gates db #1f,#bd ;Gator db #5a,#75 ;Genie db #5a,#d5 ;Genre db #5a,#fe ;Gents db #5d,#9e ;Germs db #5e,#f5 ;Geste db #71,#af ;Giant db #76,#fe ;Gifts db #7d,#8e ;Girls db #81,#ee ;Glass db #8b,#25 ;Globe db #ab,#95 ;Gnome db #b1,#8e ;Goals db #b1,#fe ;Goats db #b8,#59 ;Golem db #bb,#4e ;Goods db #bb,#e5 ;Goose db #d1,#45 ;Grade db #d1,#78 ;Grail db #d1,#7a ;Grain db #d1,#a4 ;Grand db #d1,#c5 ;Grape db #d1,#ec ;Grasp db #d5,#1f ;Great db #d7,#ae ;Grins db #db,#b9 ;Groom db #db,#ee,0 ;Gross db #1a,#4e ;Hands db #17,#de ;Hairs db #12,#7f ;Habit db #1d,#59 ;Harem db #51,#4e ;Heads db #51,#8e ;Heals db #51,#ce ;Heaps db #51,#df ;Heart db #55,#8e ;Heels db #57,#de ;Heirs db #57,#ef ;Heist db #58,#8b ;Hello db #5a,#35 ;Hence db #5d,#2e ;Herbs db #7d,#5e ;Hires db #ba,#bd ;Honor db #bd,#e5 ;Horse db #bf,#58,0 ;Hotel db #45,#18 ;Ideal db #45,#1e ;Ideas db #f5,#9e,0 ;Items db #51,#ae,0 ;Jeans db #1d,#1f ;Karat db #1d,#91 ;Karma db #78,#fe ;Kilts db #7a,#4e ;Kinds db #7f,#5e ;Kites db #a7,#65 ;Knife db #ab,#2e ;Knobs db #ab,#fe,0 ;Knots db #1a,#5e ;Lanes db #1f,#5d ;Later db #51,#4e ;Leads db #51,#e5 ;Lease db #59,#ba,0 ;Lemon db #17,#4e ;Maids db #18,#5e ;Males db #1a,#bd ;Manor db #54,#18 ;Medal db #54,#73 ;Medic db #58,#ba ;Melon db #b4,#58,0 ;Model db #17,#8e ;Nails db #19,#54 ;Named db #55,#4e ;Needs db #5d,#4e ;Nerds db #b4,#5e,0 ;Nodes db #35,#1a ;Ocean db #95,#ae ;Omens db #c5,#d1 ;Opera db #d2,#7f ;Orbit db #78,#54 ;Oiled db #d3,#1e,0 ;Orcas db #18,#9e ;Palms db #18,#5d ;Paler db #1c,#5d ;Paper db #1e,#f1 ;Pasta db #51,#d8 ;Pearl db #71,#ab ;Piano db #78,#bf ;Pilot db #81,#7a ;Plain db #b5,#9e ;Poems db #d7,#45 ;Pride db #d7,#95 ;Prime db #d7,#e5 ;Prise db #db,#25,0,0 ;Probe db #17,#e5 ;Raise db #1c,#74 ;Rapid db #1f,#5e ;Rates db #51,#3f ;React db #51,#89 ;Realm db #51,#de ;Rears db #5e,#5f ;Reset db #74,#5e ;Rides db #76,#85 ;Rifle db #7b,#fe ;Riots db #b1,#4e ;Roads db #b1,#ef ;Roast db #b2,#5e ;Robes db #b9,#1a ;Roman db #13,#5e ;Races db #bc,#5e,0 ;Ropes db #12,#85 ;Sable db #17,#af ;Saint db #1f,#7a ;Satin db #31,#8c ;Scalp db #31,#d5 ;Scare db #3b,#d5 ;Score db #51,#fe ;Seats db #7a,#35 ;Since db #7d,#5a ;Siren db #87,#45 ;Slide db #95,#1d ;Smear db #a1,#78 ;Snail db #a1,#d5 ;Snare db #b2,#5d ;Sober db #ba,#1d ;Sonar db #c1,#45 ;Spade db #c5,#1d ;Spear db #c8,#1f ;Splat db #cb,#d5 ;Spore db #f1,#7d ;Stair db #f1,#a4 ;Stand db #f1,#d5 ;Stare db #f1,#df ;Start db #f1,#f5 ;State db #f5,#18 ;Steal db #f5,#5d ;Steer db #fb,#d5 ;Store db #3b,#da ;Scorn db #f1,#74,0 ;Staid db #12,#85 ;Table db #18,#5e ;Tales db #1c,#1e ;Tapas db #1e,#f5 ;Taste db #51,#de ;Tears db #5d,#9e ;Terms db #74,#18 ;Tidal db #74,#5e ;Tides db #79,#5d ;Timer db #7d,#54 ;Tired db #7d,#5e ;Tires db #ba,#73 ;Tonic db #d1,#35 ;Trace db #d1,#45 ;Trade db #d1,#7a ;Train db #d5,#14 ;Tread db #d5,#a4 ;Trend db #d7,#14 ;Triad db #d7,#18 ;Trial db #d7,#54 ;Tried db #1c,#5d ;Taper db #78,#45,0 ;Tilde db #a4,#5d,0 ;Under db #18,#74,0 ;Valid db #1f,#5d,0 ;Water db #57,#d4 ;Weird db 0 ; X ; the display file, 25 lines dfile db 118 db "W"-27,"O"-27,"R"-27,"D"-27,0 count db 28,28,28,118,118 screen db 0,0,0,0,0,118 db 0,0,0,0,0,118 db 0,0,0,0,0,118 db 0,0,0,0,0,118 lword db 0,0,0,0,0,118 input db 0,0,0,0,0,118 eos db 118,118 ; fill the lowres screen with emptylines db 118,118,118 db 118,118 db 118,118,118 db 118 db 118,118 db 118,118 db 118,118 vars db 128 last equ $ end