viernes, 28 de diciembre de 2018

Meet the CPUs

Welcome to my blog, where I'll teach you how to program not one but various SEGA systems at once (if possible)

Before we start, this blog is meant for people with some programming experience, if you at least know BASIC, it's fine.

Keep in mind that you'll need a good amount of time to understand this (it took me 6 years), know the hexadecimal numbers (0-9,A,B,C,D,E,F) and binary (0 and 1), also interact with bits ( OR, AND, XOR/EOR ) and... the desire to do this.

These are the CPUs we are going to use:
  • Motorola 68000
  • Zilog Z80
  • Hitachi SH-2 (SH7095)
 And these are the setups of each console:
  • Master System and Game Gear:
    • Zilog Z80
  • Genesis
    • Main: 68000
    • Sound: Z80
    • If the Sega CD is connected:
      • Another 68000, nicknamed "Sub-CPU" (and the Genesis 68000 is now the "Main-CPU")
    • If the Sega 32X is connected:
      • 2 Hitachi SH-2 (SH7095) processors, "dual-core" type
**In these tutorials we are going to use 68000 as a base

- Each CPU consists of registers, condition bits and memory: the registers are like the variables that you normally use in other programming languages:

Variable = 1

All the registers are in hexadecimal and limited in size depending of the CPU:

BYTE (12)
WORD (1234)
LONG (12345678)


- The condition bits are when you make conditions to the registers:

Nothing = 0
if Nothing == 0:
  Z = 1
else:
  Z = 0

A CPU at least has these bits:

Z - Zero
Set when a register is in zeros, on conditions this is used if a value is Equal (==) or Not equal (!=)

C - Carry
This bit is set if a register runs out of bits (depending of the byte size) for example: in a BYTE where the maxium value is 255 (1111 1111) and you increment by 1, it returns to 0 (0000 0000) but the bit that makes the number 256 (1 0000 0000) stays on Carry temporally. And in conditions it's used if the value is larger than (>) and lower than (<)

N - Negative
Set if the value is negative, for example: -24, depending of the register size: gets active when the Most Significative Bit (8-bit: 1000 0000, 16-bit: 1000 0000 0000 0000) is set

V - oVerflow
Set if the value went from positive to negative in foward, example: if in 8-bit you have the number +127 (0111 1111) and increment by 1, it turns into -128 becuase the value of 128 in binary sets the negative bit (1000 0000).

The 68000 also includes a bit called X - eXtended but this can be manually set by the user

If you wanna learn more about each CPU, especially the instruction set, i'll leave these links:
https://retrocdn.net/images/3/3a/Motorola_68000_Programmer%27s_Reference_Manual.pdf
http://wpage.unina.it/rcanonic/didattica/ce1/docs/68000.pdf
http://www.z80.info/zip/z80cpu_um.pdf
https://www.renesas.com/us/en/doc/products/mpumcu/001/rej09b0171_superh.pdf

In the next post, I'll explain how to work with the memory of each console, and also to how to really start making your code...

jueves, 27 de diciembre de 2018

Conoce los CPUs

Bienvenido a mi blog, en donde enseñaré a como programar no solo una, pero varias consolas de SEGA a la vez (si es posible)

Antes de empezar, este blog solo será para gente con algo de experiencia en programación... con que sepas BASIC está bien.


También ten en cuenta que necesitarás un buen de tiempo para entender todo esto (a mi me tomó 6 años), que conoscas los numeros hexadecimales (0-9,A,B,C,D,E,F) y binarios (0 y 1), también saber como interacturar con los bits ( OR, AND, XOR/EOR ), y pues... ganas de hacer esto.

Estos son los CPUs que vamos a usar:
  • Motorola 68000
  • Zilog Z80
  • Hitachi SH-2 (SH7095)
 Y estas son las combinaciones de CPUs de cada consola:
  • Master System y Game Gear:
    • Zilog Z80
  • Genesis
    • Principal: 68000
    • Sonido: Z80
    • Si el Sega CD esta conectado:
      • Otro 68000, con el nombre de "Sub-CPU" (y el 68000 del Genesis ahora es llamado "Main-CPU")
    • Si el Sega 32X esta conectado:
      • 2 procesadores Hitachi SH-2 (SH7095) tipo "dual-core"
** En estos tutoriales usaremos el 68000 como principal.


- Cada CPU se compone de instrucciones, registros, bits de condición y memoria: los registros son como las variables que usas en otros lenguajes de programación:

Variable = 1

Pero todos los registros siempre serán valores en hexadecimal y limitado a su tamaño dependiendo del CPU:

BYTE (12)
WORD (1234)
LONG (12345678)


- Los bits de condición son para cuando haces condiciones a los registros:

Nada = 0
if Nada == 0:
  Z = 1
else:
  Z = 0

Por lo minimo estos CPUs tienen estos bits:

Z - Zero
Para cuando un registro está en Ceros, en condiciones es usado como Igual (==) o No es igual (!=)

C - Carry
Este es para cuando un registro se le acaban sus bits (dependiendo del tamaño del mismo) por ejemplo en un BYTE donde si su valor maximo es 255 (1111 1111) y le agregas 1, volverá en 0 (0000 0000) pero el bit para hacer el numero 256 (1 0000 0000) se quedará en Carry temporalmente. Y en condiciones se usa como mayor que (>) y menor que (<)

N - Negativo
Este se activa si el valor está negativo, como por ejemplo: -24, esto depende del tamaño del registro, se activa cuando el bit más significativo (8-bit: 1000 0000, 16-bit: 1000 0000 0000 0000) esté activo.

V - oVerflow
Se activa si saltas de positivo a negativo contando hacia adelante, ejemplo: si en 8-bit tienes el numero +127 (0111 1111) y agregas 1, se convierte en -128 debido a que el valor de 128 en binario activa el bit negativo (1000 0000).

El 68000 también incluye un bit llamado X - eXtended pero este se puede controlar por el usuario

Si quieres saber más de cada CPU, especialmente las instrucciones aqui les dejo unos docs:
(Nota: todo en inglés)
https://retrocdn.net/images/3/3a/Motorola_68000_Programmer%27s_Reference_Manual.pdf
http://wpage.unina.it/rcanonic/didattica/ce1/docs/68000.pdf
http://www.z80.info/zip/z80cpu_um.pdf
https://www.renesas.com/us/en/doc/products/mpumcu/001/rej09b0171_superh.pdf

En el proximo post, explicaré como trabajar con la memoria de cada consola, y también a como realmente empezar a hacer tu codigo...

martes, 25 de diciembre de 2018

PRIMER POST

Buenas a todos,

Este es mi primer post para un nuevo de blog en donde enseñaré a como programar en consolas de juegos de antes, que todavia se siguen jugando sea oficial o pirata.

Será basandome con lo que aprendí durante largos 6 años que supone era para un **gran** projecto de juego indie, pero por problemas personales, lo cancelé.

Las consolas que haré los tutoriales son:
  • Sega Genesis / Mega Drive
  • Sega CD / Mega CD
  • Sega 32X / Super 32X
  • Master System / Mark IV
  • Game Gear
Ademas, los tutoriales van a estar en dos idiomas: Español e Inglés
(y en Español "latino", para aclarar)

Espero que les guste, y a ver si no los dejo mal...

Feliz Navidad

  ⬆️
⬅️  ➡️   🅧🅨🅩
  ⬇️   ➖ 🅐🅑🅒