Karoshi MSX Community
05 de Julio de 2021, 01:14:21 pm *
Bienvenido(a), Visitante. Por favor, ingresa o regístrate.

Ingresar con nombre de usuario, contraseña y duración de la sesión
Noticias:
 
   Inicio   Ayuda Buscar Ingresar Registrarse  
Páginas: [1]
  Imprimir  
Autor Tema: searchstream.asm  (Leído 7317 veces)
0 Usuarios y 1 Visitante están viendo este tema.
SapphiRe
Visitante
« : 15 de Febrero de 2006, 06:20:53 pm »

Hi all!

  Here is a routine I've used in Namake's Bridgedrome to detect if a secondary cartrigde is present, or not, in order to activate a special feature in the game Cheesy (have you used this feature? Grin Grin )

Código:
; ------------------------------------------------
; --- BUSQUEDA DE STREAMS POR SLOTS Y SUBSLOTS ---
; ------------------------------------------------
; --- UTILIZACION                              ---
; ---        CALL SEARCHSTREAM                 ---
; --- .DW    DIRECCION,LONGITUD                ---
; --- .DB    STREAM DE DATOS A BUSCAR          ---
; --- (los datos deben estar encriptados)      ---
; ------------------------------------------------
; --- Devuelve a=0  si no lo encuentra         ---
; ---          a=1  si lo encuentra            ---
; ------------------------------------------------

SEARCHSTREAM: pop IX ; Recuperamos la direccion con los datos
ld l,[IX] ; Direccion de busqueda (baja)
inc IX ; Incrementamos
ld h,[IX] ; Direccion de busqueda (alta)
inc IX ; Incrementamos
ld c,[IX] ; Longitud de busqueda (baja)
inc IX ; Incrementamos
ld b,[IX] ; Longitud de busqueda (alta)
inc IX ; Incrementamos
; Iniciamos la busqueda por todos los Slots y Subslots
ld d,$80 ; Slot/Subslot inicial (0/0 todos ampliados)
@@BUCLE: push de ; Guardamos Slot/Subslot +1
push hl ; Guardamos la direccion de busqueda +2
push IX ; Guardamos la direccion de comparacion +3
push bc ; Guardamos la longitud +4
call @@SEARCH ; Buscamos la cadena
pop bc ; Recuperamos la longitud -4
pop IX ; Recuperamos la direccion de comparacion -3
pop hl ; Recuperamos la direccion de busqueda -2
pop de ; Recuperamos Slot/Subslot -1
or a ; Si a es igual a cero...
jr z,@@ENCONTRADO ; ...saltamos a @@ENCONTRADO
inc d ; Incrementamos Slot/Subslot
ld a,$10 ; Bit que se activa si hemos terminado
and d ; Miramos a ver si hemos terminado
jr z,@@BUCLE ; Si no, volvemos al bucle
; --- Si llegamos aqui NO hemos encontrado la cadena que buscabamos ---
xor a ; a = 0 (no lo hemos encontrado)
@@VUELVE: add IX,bc ; Direccion de retorno...
push IX ; ...en la cima de la pila
ret ; Volvemos
; --- Si llegamos aqui SI hemos encontrado la cadena que buscabamos ---
@@ENCONTRADO: inc a ; a = 1 (lo hemos encontrado)
jr @@VUELVE ; Volvemos
@@SEARCH: ; --- Subrutina que comprueba si la cadena en el Slot/Subslot D, direccion HL coincide con lo buscado ---
ld a,d ; Recuperamos Slot/Subslot
push af ; Guardamos Slot/Subslot +1
push bc ; Guardamos longitud +2
call RDSLT ; Leemos la direccion del Slot/Subslot
cp [IX] ; Comparamos con el valor que buscamos...
jr nz,@@NOT ; ...y si no es cero saltamos a @@NOT
pop bc ; Recuperamos longitud -2
pop af ; Recuperamos Slot/Subslot -1
ld d,a ; Guardamos Slot/Subslot
inc IX ; Incrementamos el origen
inc hl ; Incrementamos direccion de busqueda
dec bc ; Decrementamos longitud
ld a,b ; a = b
or c ; a = b OR c
jr nz,@@SEARCH ; Si no es cero, cerramos el bucle
ret ; Volvemos con un valor de a = 0
@@NOT: pop bc ; Restauramos la pila... -2
pop bc ; ...dos valores -1
ret ; Volvemos con un valor de a <> 0
; --- Subrutina que comprueba si la cadena en el Slot/Subslot D, direccion HL coincide con lo buscado ---

  Commentaries are in Spanish, sorry. I'll try to explain the use of the routine. You need the following data:

2 bytes: address where the stream is supossed to be (ADD)
2 bytes: length of the stream (N)
N bytes: stream of bytes

  Calling the routine:

Código:
call SEARCHSTREAM ; Buscamos el siguiente STREAM por todos los SLOTS
.dw ADD,N ; Direccion y longitud
.db stream of N bytes ; Buscamos esta cadena
next instruction...

  Example, we want to know if Antartic Adventure is present or not:

Código:
call SEARCHSTREAM ; Buscamos el siguiente STREAM por todos los SLOTS
.dw $4010,4 ; Direccion y longitud
.db $43,$44,$07,$01 ; Buscamos esta cadena (Antartic Adventure)

  And we will obtain a=0 if Antartic Adventure is not present or a=1 if it's plugged in the computer.

I hope you'll find this routine useful
--
SapphiRe
En línea
Darth_Fistro
Karoshi Hero
*****
Mensajes: 507


Email
« Respuesta #1 : 15 de Febrero de 2006, 06:32:46 pm »

Great, Sapphire!  Cheesy I wonder which game will make a surprise to appear in conjunction with Namake...  Grin

This is a very nice trick, it will be used for sure!  Cheesy

By the way, how did you detect Penguin Adv. in your example? You're only comparing 4 bytes...  Huh
En línea

MSX FOREVER (hasta que saquen un ZX81 con TMS, PSG y 64K de RAM)
jltursan
Karoshi Forum's Guru
*******
Mensajes: 1516


¿Que es lo que has aprendido hoy?


WWW Email
« Respuesta #2 : 15 de Febrero de 2006, 06:57:44 pm »

Citar
I wonder which game will make a surprise to appear in conjunction with Namake...

Which else...? Grin

Citar
how did you detect Penguin Adv. in your example? You're only comparing 4 bytes...

Prolly changing $07,$01 with $07,$43. I'm not sure if the Konami codes goes in hex or decimal; but I guess he's using the famous RC codes.

En línea

Doom dee doom dee doom
SapphiRe
Visitante
« Respuesta #3 : 15 de Febrero de 2006, 07:24:29 pm »

Citar
how did you detect Penguin Adv. in your example? You're only comparing 4 bytes...

Prolly changing $07,$01 with $07,$43. I'm not sure if the Konami codes goes in hex or decimal; but I guess he's using the famous RC codes.


Yes. All the konami games have their RC code in the $4010 address. First two bytes are allways $43 and $44, the following ones are the RC code in BCD. In the case of Antartic Adventure is RC-701, for Penguin Adventure RC-743... Is the same technique used by konami to identify the cartrigdes.

Final note: the routine I've really used in Namake's also uses a very simple encryption, to difficult to the people guess the cartrigde (or cartridges in the case of Namake's) searched...

Regards
--
SapphiRe
En línea
KNM
Karoshi Hero
*****
Mensajes: 755

Fearless

jbosca@hotmail.com
Email
« Respuesta #4 : 17 de Febrero de 2006, 07:42:55 pm »

C´mon !! It´s very easy to find wich games sapphire´s talkig ´bout  Grin Grin Grin...

Y yo hablando en english...

Por cierto Sapphire...¿recuerdas que instalé el blueMSX con el namake en el pub Texas?...Pues anteayer me acerqué a tomarme un refresco y vi a Paco y a Salva viciandose de lo lindo.Paco llego hasta la 19 en su segunda partida...

¡Hasta se apuntaron los passwords para seguir jugando!  Cheesy Cheesy Cheesy.A ver en que otro pub puedes ir a tomarte unas copas con los colegas y echar mano del bluemsx para picarte con tus compis  Wink Wink Wink

KNM
mola mola mola...
En línea

<Bacterion> : ¿ Por qué la gente se empeña en pulsar F5 ?
SapphiRe
Visitante
« Respuesta #5 : 18 de Febrero de 2006, 07:22:14 pm »

Vamos a tener que hacer la versión recreativa del Namake's... jajajaja
En línea
BiFiMSX
Karoshi Newbie
*
Mensajes: 23


« Respuesta #6 : 20 de Junio de 2006, 02:41:11 pm »

8K and 16K games don't use the "CD",7,rc-in-bcd format.
32K and megaroms do.

so Antarctic Adventure will never be detected... Penguin Adventure will.
En línea

MsxKun
Karoshi Forum's Guru
*******
Mensajes: 1554


Kimochi-ii


WWW Email
« Respuesta #7 : 04 de Octubre de 2006, 09:21:29 pm »

I thing this part isn't correct at all:

Código:
@@NOT: pop bc ; Restauramos la pila... -2
pop bc ; ...dos valores -1
ret ; Volvemos con un valor de a <> 0


beacuse if here:

Código:
call RDSLT ; Leemos la direccion del Slot/Subslot
cp [IX] ; Comparamos con el valor que buscamos...
jr nz,@@NOT ; ...y si no es cero saltamos a @@NOT

at IX is a 0 value, a will be zero, so you will return with a zero value until you didn't find the chain!! I tried and i found that. Now if you put a: LD A,1 before the RET, sure always will be a<>0. Now it works fine!

En línea

--

Cindy Lauper She Bops!
SapphiRe
Visitante
« Respuesta #8 : 05 de Octubre de 2006, 04:22:20 pm »

I thing this part isn't correct at all:

Código:
@@NOT: pop bc ; Restauramos la pila... -2
pop bc ; ...dos valores -1
ret ; Volvemos con un valor de a <> 0


beacuse if here:

Código:
call RDSLT ; Leemos la direccion del Slot/Subslot
cp [IX] ; Comparamos con el valor que buscamos...
jr nz,@@NOT ; ...y si no es cero saltamos a @@NOT

at IX is a 0 value, a will be zero, so you will return with a zero value until you didn't find the chain!! I tried and i found that. Now if you put a: LD A,1 before the RET, sure always will be a<>0. Now it works fine!

You're right... Too few people using this routine, hmmm??
En línea
Páginas: [1]
  Imprimir  
 
Ir a:  

Impulsado por MySQL Impulsado por PHP Powered by SMF 1.1.21 | SMF © 2013, Simple Machines XHTML 1.0 válido! CSS válido!