''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' ' EMPAREJA v1.1 ' ' ' ' v1.0 presentada al Concurso BASIC 2020 ' ' ' ' Categoria BASIC compilado ' ' (usar solo lo que trae ZX BASIC, no ensamblador)' ' ' ' (http://www.bytemaniacos.com/?page_id=3639) ' ' ' ' (C) EddieTheWild 2020 ' ' ' ''''''''''''''''''''''''''''''''''''''''''''''''''' #include #include #include #include const AnchoGrid as ubyte=4 const AltoGrid as ubyte=3 const FotosGrid as ubyte=AnchoGrid*AltoGrid const DimFoto as ubyte=7 ' 7x7 caracteres cada foto const FotosGaleriaTxt as ubyte=14 ' numero de "fotos" de texto en la galeria dim galeriaTxt(FotosGaleriaTxt,DimFoto) as string 'Galeria de "fotos" de texto disponible de 7x7 caracteres dim colorGaleriaTxt(FotosGaleriaTxt,3) as ubyte _ 'Colores de cada "foto" de texto => {{7,0,0},{2,0,0},{6,0,0},{4,0,0},{3,0,0},{5,0,0},{1,0,0}, _ {7,0,1},{2,0,1},{6,0,1},{4,0,1},{3,0,1},{5,0,1},{1,0,1}} ' => {{0,7,0},{0,2,0},{0,6,0},{0,4,0},{0,3,0},{0,5,0},{0,1,0}, _ ' {0,7,1},{0,2,1},{0,6,1},{0,4,1},{0,3,1},{0,5,1},{0,1,1}} ' fondo de color, texto en negro dim fotosGaleria as ubyte ' numero de fotos disponibles del tema seleccionado dim dirTilesMenu as uinteger=42000 ' dir. de carga de los tiles del menu de temas (2.6k) dim dirTileSet as uinteger=dirTilesMenu+2700 ' dir. de carga de los distintos tilesets (15.5k) dim tile(7) as string ' "fotos" compuestas de tiles en memoria referenciadas por caracteres tile(1)="#$%&'()" ' empezamos por 4º caracter del charset para evitar poner el 3º (") en un string tile(2)="*+,-./0" ' Es el equivalente a galeriaTxt(i,7) pero siempre el mismo para todos los tiles tile(3)="1234567" tile(4)="89:;<=>" tile(5)="?@ABCDE" tile(6)="FGHIJKL" tile(7)="MNOPQRS" dim fotos(FotosGrid) as ubyte '6 Fotos seleccionadas para cada partida, cada una 2 veces dim fotosMostradas(FotosGrid) as ubyte ' 1 si esta visualizada, 0 si oculta dim tema$ as string="" ' el tema de fotos seleccionado ' guardamos coordenadas x,y, y e indice del keyset que selecciona cada una de las 6 opciones de menu dim menuData(6,3) as ubyte => {{7,0,2},{18,0,3},{1,8,5},{24,8,8},{7,16,10},{18,16,11}} dim menuTema(6) as string menuTema(1)="t-LdSCR" ' tiles from loading screens menuTema(2)="t-LdSCR-Sp" ' tiles from loading screens of Spanish videogames menuTema(3)="t-InGame" ' tiles from in-game screenshots menuTema(4)="t-InGameSp" ' tiles from in-game screenshots of Spanish videogames menuTema(5)="t-Empr" ' tiles from videogame companies' logos menuTema(6)="FotosTxt" ' "fotos" de texto, creadas en run-time dim sc, hisc as ulong dim nivel,maxNivel,modoFallos,aciertos,keyset as ubyte const MaxTiempo as ubyte=184 ' num pixeles barra tiempo, unos 20 seg. (1 seg./8 pixeles) const MinTiempo as ubyte=80 ' idem, unos 8 segundos const DecrTiempo as ubyte=16 ' lo que se decrementa el tiempo en cada nuevo nivel (sin pasar de MinTiempo) dim tiempo, tiempoPartida, lentitud, nuevoTiempo as uinteger ' aunque toman valores <256 tengo que declararlas asi o al multiplicar ' sus valores... trunca el resultado a tipo byte aunque se asigne a ' una variable uinteger :-(((( ' Mensajes de como reacciona el juego ante un fallo en un emparejamiento dim msgFallos$(3) msgFallos$(1)="OK " msgFallos$(2)="\p ptos.\r " msgFallos$(3)="\p tiempo\r" const penalizacionTiempo as ubyte=16 '8 pixeles de la barra de tiempo, aprox. 1 seg. dim teclas$(12) ' las 12 teclas o cjtos de teclas para pulsar en las 12 fotos declare FUNCTION eligeTema() as string ''''''''''''''''''''''''''' ''' PROGRAMA PRINCIPAL '''' ''''''''''''''''''''''''''' inic: ' estara la pantalla de carga ' poke no necesario por la directiva -D HIDE_LOAD_MSG: POKE 23739,111 ' no sacar mensaje de carga de fichero load "tilesMenu" code dirTilesMenu paper 0: ink 7 printat42(0,4):flash 1:print42("Para el cassette y pulsa una tecla"):flash 0:pause 0 crearUDGs() border 0:cls inicReloj() hisc=0 keyset=1: confKeys(keyset) modoFallos=1 ' fallos OK, sin consecuencias nivel=1 maxNivel=7 ' Titulo DIM titulo$(5) as string titulo$(1)="\::\::\b \::\b\a\:: \::\::\b \a\::\b \::\::\b \::\::\b \::\::\:: \a\::\b" titulo$(2)="\:: \::\c\d\:: \:: \:: \:: \:: \:: \:: \:: \:: \:: \:: \::": titulo$(3)="\::\::\:: \:: \:: \::\::\d \::\::\:: \::\::\d \::\::\:: \:: \::\::\::" titulo$(4)="\:: \:: \:: \:: \:: \:: \::\c\b \:: \:: \:: \::": titulo$(5)="\::\::\d \:: \:: \:: \:: \:: \:: \:: \::\::\d \::\::\d \:: \::" Menu: cls ' do k$=inkey$ loop until k$="" ' por si se esta pulsando alguna tecla al entrar aqui print at 0,0; for i=1 to 5:print ink 1; titulo$(i);:next i beep .1,20:beep .1,20 do bold 1: PRINT AT 8,6;"1 - Jugar" PRINT AT 10,6;"2 - Cjto. teclas ";keyset print at 12,6;"3 - Nivel ";nivel; " " print at 14,6;"4 - Fallos ";msgFallos$(modoFallos) PRINT AT 16,6;"5 - Ver instrucciones" PRINT at 18,6;"0 - Salir" bold 0: print ink 6;at 23,6;"\* EddieTheWild 2020"; leerOpcion: pause 0: k$=inkey$ ' CHR$ PEEK 23560 lee del buffer if k$<"0" or k$>"5" then goto leerOpcion beep .01,50 IF k$="1" then tiempoPartida=MaxTiempo-DecrTiempo*(nivel-1): if tiempoPartida1 then s$="Fallos "+msgFallos$(modoFallos): print ink 6;at 0,15-(len s$)/2;s$ h$="Record: "+str$(hisc)+" " ink 6:printat42(23,1):print42(h$):ink 7 printPtos() k$="" ' Bucle de juego do tiempo=tiempo-1 if (tiempo mod lentitud)=0 then plot over 1;paper 8;ink 8;240,alturaBarra:draw over 1;paper 8; ink 8;7,0 alturaBarra=alturaBarra-1 end if ' print at 0,0;"t.part:";tiempoPartida;" t.:";tiempo;" ciclos:";ciclos;" ":pause 0 dim n as ubyte=0:kk$=k$ k$=inkey$: if k$="" or k$=kk$ then goto nuevoCiclo ' asi se comprueba la tecla pulsada una vez, sin repeticiones (para evitar congelar el tiempo) for i=1 to 12 if instr(teclas$(i),k$)<>0 then n=i: goto teclaValida ' exit for next i ''''' BACKDOORS '''' 'if k$="-" then ' aciertos=6:goto finNivel ' backdoor key nivel completado 'elseif k$="." aciertos=0:goto finNivel ' backdoor key game over 'end if '''''''''''''''''''' goto nuevoCiclo ' han pulsado tecla no valida teclaValida: if fotosMostradas(n)=1 then ' hemos pinchado en la posicion de una ya mostrada, no hacemos nada beep 0.0001,40 else verFoto(n) if foto1=0 then 'no habia mostrada ninguna beep 0.001,0: foto1=n elseif fotos(foto1)=fotos(n) then ' ES LA MISMA FOTO!! se quedaran abiertas aciertos=aciertos+1 beep 0.05,10:beep 0.05,20 foto1=0 sc=sc+50*nivel printPtos() if aciertos=6 then for j=1=-10 to 60: beep 0.005,j:border 8*rnd: next j: border 0 else ' La pinchada NO COINCIDE con la ya abierta, ocultamos ambas y penalizamos si modoFallos=2 o 3 beep 0.5,-20 ocultaFoto(foto1):ocultaFoto(n):foto1=0 if modoFallos=2 then ' restar ptos. dim decr as ulong=50*nivel if sc>decr then sc=sc-decr ' para no truncarlo al pasar a negativo siendo ulong else sc=0 end if printPtos() elseif modoFallos=3 and tiempo>0 then ' restar tiempo si aun resta algo pen=penalizacionTiempo if alturaBarra+10 then for i=0 to alturaBarra ' ptos. extra por tiempo restante extra=extra+10*nivel e$=str$(sc)+"+"+str$(extra)+"="+str$(sc+extra) plot over 1;paper 8;ink 8;240,alturaBarra-i:draw over 1;paper 8; ink 8;7,0 print at 12,15-(len e$)/2;e$;" "; beep 0.0001, 30 next i end if sc=sc+extra waitDecSec(10) 'if hisc>0 and sc>hisc then ' print at 13,4;flash 1;" HAS BATIDO EL RECORD!! " ' for i=1 to 3:for j=30 to 60: beep 0.002,j:beep 0.002,j-20:next j:next i ' hisc=0 ' hara que el record siga la misma puntuacion que sc, sin decir que se ha batido el record a cada nivel 'end if tiempoPartida=tiempoPartida-DecrTiempo ' decrementamos el tiempo para la proxima partida if tiempoPartida1 then lentitud=lentitud-1 nivel=nivel+1 else print at 11,10;flash 1;"GAME OVER" for i=0 to 8: beep 0.2,-i:next i:beep 1,-9 if sc>hisc then print at 13,4;flash 1;" HAS BATIDO EL RECORD!! " ' se comprueba solo al acabar la partida no al acabar los niveles for i=1 to 2:for j=30 to 60: beep 0.002,j:beep 0.002,j-20:next j:next i hisc=sc end if if nivel>maxNivel then maxNivel=nivel goto Menu ' Vuelve al menu principal end if goto nuevoNivel ' continua la partida ''''''''''''''''''''''''''''''' ''''''' SUBRUTINAS ''''''' ''''''''''''''''''''''''''''''' ' Recuadra con caracteres con flash marcar el tile de la coordenada indicada SUB recuadraChr(xx as ubyte, yy as ubyte, marcar as ubyte) if yy>0 then print at yy-1,xx-1;ink 8;flash marcar;paper 8;bright 8;over 1;" "; for j=yy to yy+6 print ink 8;flash marcar;paper 8;bright 8;over 1;at j,xx-1;" ";at j,xx+7;" "; next j if yy<23 then print at yy+7,xx-1;ink 8;flash marcar;paper 8;bright 8;over 1;" "; END SUB ' Permite elegir el tema de las fotos con las que se jugara FUNCTION eligeTema() as string dim t$ as string="" dim selected as ubyte=0 dim x,y,xa,ya as ubyte cls bold 1:print at 11,11;"ELIGE TEMA":bold 0 for i=1 to 6 printTile(i,dirTilesMenu,menuData(i,1),menuData(i,2),1) next i FOR i=10 TO 40 STEP 3: BEEP 0.005,i: BEEP 0.005,i-10: NEXT i xa=0 do pause 0:k$=inkey$ for i=1 to 6 if instr(teclas(menuData(i,3)),k$) then if selected=i then beep 0.05,30 t$=menuTema(i) goto temaSeleccionado elseif selected then beep 0.05,0 recuadraChr(xa,ya,0) selected=0 print at 13,14;" " else beep 0.05,20 print at 13,14;"\uOK?" x=menuData(i,1): y=menuData(i,2) recuadraChr(x,y,1) xa=x: ya=y selected=i end if exit for end if next i loop temaSeleccionado: 'print at 13,14;"'";t$;"'" if t$=menuTema(6) then ' si se elegio el sexto tema, tiles de texto ' print at 11,11;"Creando..." crearGaleriaTxt(FotosGaleriaTxt,DimFoto,DimFoto) fotosGaleria=FotosGaleriaTxt elseif t$<>tema$ then print at 13,14;" " print at 11,11;"Cargando.." ' poke no necesario por la directiva -D HIDE_LOAD_MSG: POKE 23739,111 ' no sacar mensaje de carga de fichero load t$ code dirTileSet fotosGaleria=36 flash 1 printat42(11,13) print42("Para el cassette "): printat42(12,13) print42("y pulsa una tecla") beep 0.05,20 flash 0:pause 0 end if ' en caso contrario, han elegido el tileset que ya estaba cargado en memoria return t$ END FUNCTION ' Carga num de anchura x altura en la galeria SUB crearGaleriaTxt(num as ubyte, anchura as ubyte, altura as ubyte) ' randomize cls select$="" for i=1 to num memCopy(rnd*7000,16384,6144) ' con color 6912 beep 0.000005,60 ' print at 11,8;"Creando foto ";i; do s$="" c$=chr$(33+95*rnd) loop until instr(select$,c$)=0 ' elegimos uno que no se haya elegido ya select$=select$+c$ for j=1 to anchura s$=s$+c$ next j for j=1 to altura galeriaTxt(i,j)=s$ 'print at 10,5;s$ next j next i END SUB ' selecciona las 6 fotos de la galeria del tema seleccionado que formaran el grid de la partida. SUB selectFotos() dim f,m,n as ubyte for i=1 to FotosGrid: fotos(i)=0: next i select$="" n=1 for i=1 to FotosGrid/2 ' elegimos la mitad porque habra dos de cada do f=int(fotosGaleria*rnd)+1 ' print at 10,1;"foto=";f;" " w$=str$(f)+" " if f<10 then w$="0"+w$ loop until instr(select$,w$)=0 select$=select$+w$ ' print at 0,0;select$ while fotos(n)<>0 n=n+1: ' print at 11,1;"n=";n;" " wend ' la foto elegida ira a continuacion, en la posicion x o la siguiente libre fotos(n)=f ' print at 15,0;"foto ";f;" a las posiciones ";n; n=n+1 do m=int((FotosGrid-n+1)*rnd)+n ' posicion en la que se colocara su segunda aparicion loop until fotos(m)=0 fotos(m)=f ' otra vez la misma next i /' print at 4,0;"Fotos elegidas:";select$ for j=0 to FotosGrid-1: f=fotos(j+1) if tema$=menuTema(6) then tinta=colorGaleriaTxt(f,1) fondo=colorGaleriaTxt(f,2) brillo=colorGaleriaTxt(f,3) else tinta=7: fondo=0: brillo=0 end if print at 5+j/AnchoGrid, 3*(j mod AnchoGrid); ink tinta; paper fondo; bright brillo;f next j: pause 0 '/ END SUB ' Oculta la foto n en su posición, segun dimensiones del grid SUB ocultaFoto(num as ubyte) dim i,x,y,n as ubyte n=num-1 x=1+(n mod AnchoGrid)*DimFoto y=1+int(n/AnchoGrid)*DimFoto print ink 2;at y,x;"\e\f\f\f\f\f\g"; for i=2 to DimFoto-1 print ink 2;at y+i-1,x;"\k\n\n\n\n\n\l" ' "\s\s\s\s\s\s\s" next i print ink 2;at y+DimFoto-1,x;"\h\i\i\i\i\i\j"; bold 1: print ink 8;at y+DimFoto/2,x+DimFoto/2;"?":bold 0 fotosMostradas(num)=0 END SUB ' Llamada para mostrar una foto dada, del tipo que sea SUB verFoto(num as ubyte) if tema$=menuTema(6) then ' si tema "fotos" de texto verFotoTexto(num) else verTile(num) end if fotosMostradas(num)=1 END SUB ' Visualiza la foto de posicion n (1-12) en pantalla, copiando los bytes de memoria a pantalla directamente SUB verTile(num as ubyte) dim x,y,n as ubyte n=num-1 x=1+(n mod AnchoGrid)*DimFoto y=1+int(n/AnchoGrid)*DimFoto printTile(fotos(num),dirTileSet,x,y,0) 'print at 0,0;"Tile ";f+1;" en pos.:";n+1;" ";:pause 0 END SUB ' Dibuja el tile num del tileset de la direccion de memoria dir, en (x,y), ' recuadrado si se indica SUB printTile(num as ubyte, dir as uinteger, x as ubyte, y as ubyte, recuadrado as ubyte) dim i,f as ubyte dim dirTile,diratrTile,d1,d2,chars as uinteger f=num-1 dirTile=dir+441*f diratrTile=dirTile+392 chars=peek(uinteger, 23606) ' guardamos la direccion del juego de caracteres actual poke uinteger 23606, dirTile-256-3*8 ' apuntamos CHARS al comienzo del tile (que sera el 4º caracter del charset, "#") FOR i=0 TO DimFoto-1 print at y+i,x;tile(i+1); ' atributos color d1=diratrTile+7*i d2=22528+32*cast(uinteger, y+i)+x MemCopy(d1,d2,7) ' copia a memoria de atributos de pantalla NEXT i poke uinteger 23606,chars ' restauramos el juego de caracteres anterior if recuadrado then recuadra(x,y,8,-1) 'print at 0,0;"Tile ";f+1;" from dir";dir:pause 0 END SUB ' Visualiza la foto (de texto) de posicion n (1-12) en pantalla, segun dimensiones del grid SUB verFotoTexto(num as ubyte) dim i,n,f,x,y, tinta,fondo,brillo as ubyte f=fotos(num) n=num-1 x=1+(n mod AnchoGrid)*DimFoto y=1+int(n/AnchoGrid)*DimFoto tinta=colorGaleriaTxt(f,1) fondo=colorGaleriaTxt(f,2) brillo=colorGaleriaTxt(f,3) for i=0 to DimFoto-1 print at y+i,x;ink tinta;paper fondo;bright brillo;galeriaTxt(f,i+1); next i recuadra(x,y,tinta,0) END SUB ' recuadra con un cuadrado alrededor del tile de 7x7 car. en la coordenada indicada ' con el offset (-n,n) indicado en pixeles SUB recuadra(x as integer, y as integer, color as ubyte, offset as integer) dim lx as integer=55-offset*2 dim ly as integer dim xx,yy as integer ' todo como integer para evitar downcastings no deseados :-( ly=lx: xx=x*8+offset: yy=y*8+offset if xx<0 then lx=lx-abs(xx): xx=0: if xx+lx>255 then lx=255-xx: if yy<0 then ly=ly-abs(yy): yy=0: if yy+ly>191 then ly=191-yy: plot over 1;ink color;paper 8;bright 8;xx,191-yy draw over 3;ink color;paper 8;bright 8;lx,0 draw over 3;ink color;paper 8;bright 8;0,-ly draw over 3;ink color;paper 8;bright 8;-lx,0 draw over 3;ink color;paper 8;bright 8;0,ly-1 over 0 END SUB ' muestra puntos SUB printPtos() s$="Ptos.: "+str$(sc)+" " ink 6:printat42(23,21):print42(s$):ink 7 END SUB ' Dibuja la barra vertical de tiempo desde 0 hasta el valor indicado en pixeles (sera multiplo de 8) ' maximo -> constante MaxTiempo) SUB barraTiempo(temp as ubyte) if temp> MaxTiempo then temp=MaxTiempo col=4 for i=23 to 24-temp/8 step -1 if i<14 then col=4 elseif i>20 then col=2 elseif i>15 then col=6 end if print at i,30;paper 0;ink col;"\::"; beep 0.001,30-i next i END SUB ' Pone a cero el reloj del sistema SUB inicReloj() POKE 23672,0: POKE 23673,0: POKE 23674,0 END SUB FUNCTION getFrames() as ulong return (PEEK 23672+256*(PEEK 23673)+65536*(PEEK 23674)) END FUNCTION ' Devuelve un string formateado con la hora del reloj del sistema FUNCTION mostrarReloj() as string dim horas, min, seg as ubyte dim frames,fr2, s as ulong dim resto as uinteger frames=getFrames() fr2=getFrames(): if fr2>frames then frames=fr2 ' para evitar leer en mitad de un cambio, cogemos la lectura mayor s=INT (frames/50): horas=INT (s/3600): resto=s-3600*horas: min=INT (resto/60): seg=resto-60*min w$=str(horas)+" horas, "+str(min)+" min., "+str(seg)+" seg. " return w$ END FUNCTION ' Devuelve un string con los frames (1/50=0.02 seg.) transcurridos FUNCTION mostrarFrames() as string dim frames as ulong frames=getFrames() w$=str(frames)+" frames" return w$ END FUNCTION ' Espera las decimas de segundo indicadas. Pause t acaba si se pulsa una tecla SUB waitDecSec(t as ubyte) dim z1,z2,z3 as ulong for l=1 to t for c=1 to 650 ' tardara 0.1 seg. aprox. z1=8000:z2=8000 z3=z1*z2 next c next l END SUB /' repe: print "Decimas de segundo? "; segundos=val(input(3)) print segundos: beep 0.1,20 waitDecSec(segundos) beep 0.1,20 goto repe '/ DIM UDG(21,8) as ubyte => {{1,3,7,15,31,63,127,255},{128,192,224,240,248,252,254,255},{255,127,63,31,15,7,3,1},_ {255,254,252,248,240,224,192,128},{127,162,136,162,136,162,136,162},{255,34,136,34,136,34,136,34},_ {254,35,137,35,137,35,137,35},{136,162,136,162,136,162,136,127},{136,34,136,34,136,34,136,255},_ {137,35,137,35,137,35,137,254},{136,162,136,162,136,162,136,162},{137,35,137,35,137,35,137,35},_ {136,34,136,34,136,34,136,34},{85,170,85,170,85,170,85,170},{16,48,112,255,255,112,48,16},_ {8,12,14,255,255,14,12,8},{24,60,126,255,24,24,24,24},{24,24,24,24,255,126,60,24},_ {8,12,242,129,129,250,12,8},{32,32,56,124,124,124,56,56},{0,16,0,16,32,66,60,0}} SUB crearUDGs() poke uinteger 23675, @UDG(1,1) ' dir=65368 'for i=0 to 19:for j=0 to 7:poke usr "a"+i*8+j,UDG(i+1,j+1):next j:next i ' w$="\s\s\s\s\s\s\s" ' print w$:print "\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u":pause 0 END SUB SUB instrucciones(cjtoteclas as ubyte) for i=7 to 21:print at i,0;" ";:next i printat42(8,0):print42("Veremos durante 3 seg. una matriz de 4x3") printat42(9,0):print42("fotos (6 fotos repetidas 2 veces).") printat42(10,0):print42("Luego se ocultaran y deberas descubrir las") printat42(11,0):print42("parejas pulsando en ellas de forma") printat42(12,0):print42("consecutiva antes de finalizar el tiempo.") print at 14,0;"Teclas para la matriz de 4x3:" w$=teclas(12):c=8 if cjtoteclas=2 then v$=w$(1)+"" ' para evitar cambiar de linea al mostrar el chr$(13) c=c-4 else v$=w$ end if print ink 4;at 16,c;"'";ucase(teclas$(1));"' '";ucase(teclas$(2));"' '";ucase(teclas$(3));"' '";ucase(teclas$(4));"'" print ink 4;at 17,c;"'";ucase(teclas$(5));"' '";ucase(teclas$(6));"' '";ucase(teclas$(7));"' '";ucase(teclas$(8));"'" print ink 4;at 18,c;"'";ucase(teclas$(9));"' '";ucase(teclas$(10));"' '";ucase(teclas$(11));"' '";ucase(v$)+"'" /' sep$="'" 'chr$(34) for i=1 to 11 print ink 4;at 16+((i-1)/4),c+4*((i-1) mod 4);sep$;ucase(teclas$(i));sep$; next i print ink 4;at 18,c+12;sep$;ucase(v$);sep$ '/ print at 21,1;"Pulsa una tecla para continuar"; pause 0 w$=CHR$ PEEK 23560: BEEP .01,20: for i=7 to 21:print at i,0;" ";:next i END SUB ' configura un keyset SUB confKeys(k as ubyte) if k=1 then teclas$(1)="1": teclas$(2)="2": teclas$(3)="3": teclas$(4)="4" teclas$(5)="q": teclas$(6)="w": teclas$(7)="e": teclas$(8)="r" teclas$(9)="a": teclas$(10)="s": teclas$(11)="d": teclas$(12)="f" else teclas$(1)="12": teclas$(2)="345": teclas$(3)="678": teclas$(4)="90" teclas$(5)="qw": teclas$(6)="ert": teclas$(7)="yui": teclas$(8)="op" teclas$(9)="as": teclas$(10)="dfg": teclas$(11)="hjk": teclas$(12)="l"+chr$(13) end if END SUB SUB salir() PRINT INK 6; FLASH 1;at 21,0;"Realmente quieres salir? (s/n)"; pause 0 w$=CHR$ PEEK 23560: BEEP .01,20: IF w$="s" THEN CLS : PRINT at 6,1;"Gracias por jugar a 'EMPAREJA'" print at 8,12;"durante" print at 10,4;mostrarReloj() print print at 14,6;"\* EddieTheWild 2020" goto adios else PRINT PAPER 0; INK 6; FLASH 0;AT 21,0,, endif END SUB adios: 'salir del programa '''''''''''''''''''''''''''''''''''''' ''' RUTINAS PROBADAS Y DESCARTADAS ''' '''''''''''''''''''''''''''''''''''''' /' ' Visualiza la foto n (1-12), copiando los bytes de memoria a pantalla directamente SUB verFoto(num as ubyte) dim i, j, xmem, ymem, x,y,b,yy,n as ubyte dim diratrTiles, dirmem, dirscr, d1,d2,incr as uinteger n=num-1 xmem=7*(n mod 4) ' coordenadas en memoria. Los tiles estan en un grid de 4x3, de (0,0) a (28,28) ymem=7*int(n/4) x=1+(n mod AnchoGrid)*DimFoto y=1+int(n/AnchoGrid)*DimFoto diratrTiles=dirTiles+6144 FOR j=0 TO 6 b=ymem+j yy=y+j dirmem=dirTiles+2048*INT (b/8)+32*(b-8*INT (b/8))+xmem dirscr=16384+2048*INT (yy/8)+32*(yy-8*INT (yy/8))+x for i=0 to 7 ' copia las 8 filas de pixeles de una fila de caracteres incr=256*i d1=dirmem+incr d2=dirscr+incr MemCopy(d1,d2,7) ' copia a memoria de pantalla el ancho del tile next i d1=cast(uinteger, diratrTiles+32*cast(uinteger,(ymem+j))+xmem) d2=cast(uinteger, 22528+32*cast(uinteger, (y+j))+x) MemCopy(d1,d2,7) ' copia a memoria de atributos de pantalla NEXT j END SUB '/ /' SUB crearTiles() dim f as ubyte load "tiles-emp" code dirTilesSet border 0: cls inicReloj() for f=1 to 12 verFoto(f) next f print at 22,0;mostrarReloj() print at 23,0;mostrarFrames() pause 0 END SUB '/ /' SUB crearTiles() load "tilesEmpr" code dirTilesSet fotosGaleria=36 for i=0 to fotosGaleria/FotosGrid-1 for j=1 to FotosGrid ' vamos seleccionandolas de 12 en 12 para luego mostrarlas fotos(j)=i*12+j next j border 0: cls inicReloj() for f=1 to FotosGrid verTile(f) next f print at 22,0;mostrarReloj() print at 23,0;mostrarFrames() pause 0 next i END SUB '/