Translate

domingo, 15 de septiembre de 2019

CoCo/Dragon Floppys

La TANDY TRS-80 Color Computer de Radio Shack utiliza floppy drivers de 5 1/4 de una sola cara y baja densidad, usando RS-DOS solo usa 35 pistas de las 37 posibles con esas unidades. Ni siquiera llegaban a las 40 pistas normales (Baja densidad 360kb) y mucho menos a 80 pistas

Usando unidades Floppys de PC 5 1/4 de 1.2 MB

Para usar Floppys de 5 1/4 de 160k o de 360kb hay pocos problemas pero para usar de 1.2 Mb si los hay
Normalmente las unidades de 1.2Mb giran a una velocidad de 360 RPM (Revoluciones por minuto)(Revolutions Per Minute) y no 300 como las primeras, ademas, pueden escribir 80 pistas, 2 caras y escriben 512 bytes por sector y no 40 pistas, 1 cara y 256 por sector, por estas diferencias es difícil usarlos con la coco y otras retro computadoras

Si la unidad tiene los jumpers de densidad normal y velocidad de 300 RPM es posible que funcione para escribir y leer sus propios discos pero escribiría solo en la primera mitad del disco, porque usarían los primeros 40 tracks.

Por ejemplo las unidades:
Manual Panasonic JU-475 pdf
Panasonic MSD891122000_JU-475-4_Service_Man.pdf
PA475-4f.htm Manual Panasonic PA-475-5 pdf
MITSUBISHI.txt
Manual Teac FD-55GFR 1.2MB pdf

FloppyDrivesJumperSettings pdf muchos floppys
Floppy drive Jumper question pdf muchos floppys, resumido
Diskette Configuration Guide 40200A03 muchos floppys con setting ya para leer con coco/Dragon
Diskette Configuration Guide 40200A03 otro sitio, mismo archivo.

Gran pagina retrotechnology herbs stuff drive

No reconocerán floppys creados con las unidades originales porque aun leerá y escribirá 80 tracks.

Usando unidades Floppys de PC 3 1/2 de 1.44 MB

diskettes-jumpers 3,5 1.44mb pdf
3.5" Compact Floppy Disk Drive D359M3D, D353M3D 1 Inch Height Type

Cable

Se utilizara un cable plano preferiblemente sin la trenza del floppy "A" aunque también serviría
No usar el cable de la coco pues le faltan dientes.

Pines del cable  (el segundo es casi el de la coco, solo que el 32 es Select Drive 3, en la coco), para verlo mejor, visite CoCo Floppys (Ajuste, Leds y otros).
Pin Name Dir Description      (Shugart interface)   COCO
2 /REDWC --> Density Select  /DCD --> Disk Change Detect
4 n/c    Reserved  /INUSE   A common open-collector LED driver signal? I have never seen this signal used anywhere.
6 n/c   Reserved  /DS3   Device Select 3. Not sure but Amiga 500s schematics reveal that this signal might be used for motor control of internal DF1: on the Amiga 2000
8 /INDEX <-- Index   /INDEX <-- Index
10 /MOTEA --> Motor Enable A  /DS0 --> Device Select 0
12 /DRVSB --> Drive Sel B  /DS1 --> Device Select 1
14 /DRVSA --> Drive Sel A  /DS2 --> Device Select 2
16 /MOTEB --> Motor Enable B  /MTRON --> Motor On
18 /DIR --> Direction  /DIR --> Direction
20 /STEP --> Step   /STEP --> Step
22 /WDATE --> Write Data  /WDATE --> Write Data
24 /WGATE --> Floppy Write Enable /WGATE --> Floppy Write Enable
26 /TRK00 <-- Track 0   /TRK00 <-- Track 0
28 /WPT <-- Write Protect  /WPT <-- Write Protect
30 /RDATA <-- Read Data  /RDATA <-- Read Data
32 /SIDE1 --> Head Select  /SIDE1 --> Head Select /DS3   Device Select 3
34 /DSKCHG <-- Disk Change/Ready /RDY --> Drive Ready/Disk Changed

Todos los impares son OV o tierra
3 n/c    Reserved   no pin in this position


Alineación

Aquí se puede ver como alinear una unidad, pero requiere de un disco especial y un osciloscopio
Tandy CoCo MiniDisk Service Manual pdf
COCO Floppys, PC 160 | PC 360kb | PC 1.2Mb



ATARI 800 XL

Tengo varias Atari 800 XL (NTSC), tratare de comparar las diferentes versiones que tengo, y reparar alguna que va mal


PLACA CO61851 REV C 800XL CA061854
U 1 - LM35BP         Precision Centigrade Temperature Sensors
U 2 - 74LS138PC    1-OF-8 Decoder/Demultiplexer
U 3 - CO61618         MMU
U 4 - CO24947A-01 ROM Basic Rev. C
U 5 - CO61598B-29 ROM Atari OS v2
U 6
U 7  - CO21697-01   ANTIC-E (Enhanced)  (Patillaje)
U 8  - CO14806-12   CPU 6802
U 9-U16 - 4264-15   8x 64k RAM
U17 - CO14805-01   GTIA
U18 - SN74LS08N   Quad 2-Input and gate
U19 - SN74LS14N   Schmitt Triggers Dual Gate/Hex Inverter
U20 - 8432A1           Hex non inverter buffer
U21 -
U22 - CO12294-31          POKEY  (Sonido)
U23 - CO14795-12          PIA         (Joysticks)
U24-U25 CD4051BE      CMOS Analog Multiplexers/Demultiplexers with Logic Level Conversion
U26-U27 SN74LS158N  QUAD 2-INPUT MULTIPLEXER
U28 - SN74LS375N        4-BIT D LATCH
U29 - CO60472-D           Delay Line U30 - SN74LS51N          Dual 2-wide 2-input/3-input and-or-inverter gate
crystal CO61090
modulator UM1652 (channel 2/3 switch input)

http://www.atarihq.com/danb/AtariChips.shtml
http://atarinside.dyndns.org/blog/index.php/motherboards/
http://mixinc.net/atari/a8men.htm

Atari OS v1 83.11.03.rom es del 600XL
Atari OS v2 83.10.05.rom es del XL/XE
Atari OS v3 85.01.03.rom es del 800XE
Atari OS v4 87.07.05.rom es del XEGS

Atari versiones PAL & Secan
http://www.atari800xl.eu/public/800xlpal/


For your information, the results are:
PEEK(53268) = 1
PEEK(65528) = 140
PEEK(65527) = 2
PEEK(43234) = 96


Atari 8-Bit Computers: Frequently Asked Questions
http://faqs.cs.uu.nl/na-dir/atari-8-bit/faq.html

SIO2PC - Atari se conecta al PC






Uno de los creadores de esta conexión es este polaco de donde tome mucho de lo que hay acá, muchas gracias http://sdq.czweb.org/old_computers/atari/pclink/sio2pc.html

http://raster.atariportal.cz/hw/sio2pc.htm
http://pages.suddenlink.net/wa5bdu/readme.txt

Tutorial de SIO2PC
Atariteca Conector usb de atari-pc

Se requiere de un programa para comunicar ambos equipos - como, por ejemplo, el freeware AspeQt, que puede emular periféricos de Atari, Otro puede ser el APE o el Atari File Management





Este tema es muy trillado pero aun haré un resumen para mi

Este interfaz es la manera mas sencilla de introducir programas en un Atari 800XL y similares.
Los métodos normales para leer y grabar programas en el Atari son:

  • Cassette
  • Floppy
  • Cartuchos ROM
  • Disco Duro (Por medio de un interface IDE)
  • Solución con Tarjeta SD, 
  • Solución con Tarjeta Flash,
  • Solución Multi ROMS,
  • Controlador o Rasperri PI que hace de esclavo

Por supuesto si tienes estos equipos no sera muy útil este cable ya que lo que hace es imitar una unidad de disco conectada al Atari, en realidad usamos un cable serial y un pequeño circuito para conectarla a un PC, En el PC hay un programa ya estandarizado que hace el trabajo de comunicación.

El puerto normal para ser usado en el Atari seria el SIO de 13 pines que es un puerto de comunicaciones serial con un enchufe bastante extraño y niveles de 5v TTL

Fuente

Descripción del conector ATARI SIO (Macho)
1-Entrada de reloj
2-Salida de reloj
3-Entrada de datos
4-Tierra
5-Salida de datos
6-Tierra
7-Comandos
8-Control del motor
9-Confirmación
10-+ 5V / Listo
11-Entrada de audio
12-+ 12V
13-interrupción



Descripción puertos COM de PC
COM 1
descripciónCOM 2
9 pines (macho)25 contactos (macho)
1DCD8
2RD3
3TD2
4DTR20
5SG7
6DSR6
7RTS4
8CTS5
9RI22

Los voltajes que maneja el puerto serial del PC (unos 10V) dañarían los puertos del Atari que son de 5V, aunque tal vez directamente se pudieran comunicar, no creo que alguien se atreva

Para adecuar los voltajes algunas personas utilizan uno de los siguientes integrados:
SN75189N; MC1489N; 14C89; 75LS189; 75C189; LM1489, Como Aquí o Aquí con buenas fotos

Pero lo mejor es usar el integrado MAX232 como Aquí
O Asi
El integrado necesita 5 condensadores, 4 de ellos deberían ser de un valor de 1uF según el datasheets pero en el esquema usan de 22uF.

Otra curiosidad es que no hay circuitos que usen el MAX233A que no necesita los condensadores externos, me imagino que los lleva dentro, y para usarlo algunos de los terminales correspondientes a los condensadores hay que puentear los o dejarlos libres (Aun no se).

El MAX233 de 120kbps es algo mas lento que el MAX232 unos 200kbps según el datasheets así que es mejor usar el MAX233A, aunque al final son mucho mas rápidos de lo necesario, unos 19.200Bd, que podriamos convertir sin mucho error en 19kbps. 

Fig. 1.
También es conveniente el SW1 que permite alternar el terminal de control del puerto COM (DSR pin 6 o RI pin 9) que depende del programa a usar.

En el anterior esquema también se ven dos tipos de terminal en el lado del PC, un DB9 y un DB25 y sus conversiones.

El esquema es simple pero evita la conexión simultánea a otros periféricos, incluyendo Atari cassette Dataset. La razón es obvia: la conexión directa de la salida del MAX 232 (baja impedancia) a una entrada de datos de Atari.

El problema puede ser eliminado, por ejemplo, por el uso de un diodo y una resistencia, como en la Fig. 2.

Fig. 2.
Otra mejora es la salida de PC no alimenta al circuito a través de Atari MAX 232, sino a través del transistor T1. En reposo, el circuito de alta impedancia y no afecta a cualquier otro periférico. En lugar de T1 se puede utilizar en casi cualquier otro transistor NPN para colocar otro diodo D1 rápido (Schottky).

En el esquema de la Fig. 2 y 3 se dibujan intencionalmente dos conectores Atari SiO, y conectado en paralelo. Una de las mujeres que participan en Atari, uno será macho y en ella podemos involucrar a otra periferia. En ambos casos, la interfaz también se puede conectar entre otros dos dispositivos (si los hay). El orden no debe importar, como con los periféricos originales Atari. Si la interfaz sólo funciona en conjunción con un conjunto de datos de panel es ninguna necesidad de involucrar a la articulación marcada con una línea de puntos
Fig. 3.
Para mas detalles vea Aquí, y tradúzcalo.

Aquí otro esquema con LEDs

Links importantes

Autores de video juegos con paginas interesantes

Al parecer mattias gustavsson hizo muchos juegos para PC, muchos se pueden descargar,
http://mattiasgustavsson.com/ y su blog antiguo http://mattiasgustavsson.com/Blog/

hay una versión ya cerrada de sus paginas Aqui. antiguamente estaban en:
http://www.retrogamedev.org/retrobox/StartingtheRetroBoxProjec.php, Pero ya no existe

Entre los juegos que tiene pueden ver: Juegos
x-com-one-of-my-all-time-favorite-games
Making a C64 Text Adventure in php
Blur and Bleed Running Games on a TV
Creando un retro arcade: Retrobox

-------------------------------OUTRUN-----------------------------------
RunOut un juego para PC del mitico OutRun
Algunos datos retro-amor-run
Datos de creación de juegos 14-cursos-para-aprender-a-crear-videojuegos-desde-cero
Interesante ver los 2 primeros vídeos resurgimiento-juegos-carreras-arcade
Ver el OUTRUN Varios juegos con fuentes
Mas profundamente Aqui

Juegos Sega Deamcast

Gran consola la Dreamcast, poco conocida donde vivo, acá en Venezuela se uso mas la Play Station, pero viéndola en retrospectiva es un gran equipo.

Para ejecutarlos usare nullDC, el cual me costo mas de lo esperado en poder usarlo, prácticamente todos lo usaban y yo no veía la forma, así que mejor lo explico.
   Después de instalar o mas bien, copiar o desemcriptar, en una carpeta lo necesario, puedes ejecútalo y si todo va bien abrirá varias ventanas, una negra mostrando todo lo que hace y en otra se mostrara el juego, esta ventana tiene unos menus, como estos: (Por cierto a veces se ocultan)

Inicialmente abrimos File y dice "Normal Boot", pero que bootea, no dice nada de si bootea un CD virtual colocado en la PC.
Pero espera tambien dice OPEN Y LOAD, que es eso, no es lo mismo Abrir que cargar, pues anda, y ademas abre un Bin? el ejecutable o un iso tipo BIN y otra cosas mas que cosa  es "elf " un elfo?, jajajaja.

En el segundo menú, ahh acá si es, Start, lógico por acá empieza, pues no, nada que ver, porque si bien puedes arrancar un juego pero no lo puedes elegir.

Pues resulta que es el primero, Si el Normal Boot, al darle pide un archivo CDI y ya lo corres, pero si quieres otro ya no sale este seleccionador de archivos.


Para elegir otro te quedan 2 soluciones, o cierras el emulador y lo abres de nuevo, o en el tercer menu el de opciones usas seleccionar GDROM (que no se que es muy bien) / Select Default Image. Que, al parecer, es para que siempre juegues lo mismo y nada para que te cuento, el que hizo este magnifico emulador se fumo algo al hacer los menus.




Luego el tema del teclado y los mandos (Joysticks)
El SHIFT es el Start, las flechas funcionan
Para cambiar el teclado hay que entrar en MAPLE (valla usted a saber, soy nuevo en esto)

No he logrado usar e

Veamos algunos de sus juegos:

18 Wheeler American Pro Trucker
Gran juego de carreras y choques de camiones, si nunca te has montado en un camión esto te gustara. Gran música
















Aero Dancing Jikai Saku Matemasen
Curioso y muy detallado simulador de vuelo, hay que aprender todos los comandos, al final no llegue a saber si es que bailas con el avión, (por lo de Dancing).


Aero Wings 2
Otro simulador con el mismo motor del anterior




Air Force Delta
Simulador de combate aéreo, tambien muy bueno

Blue Stinger
Buen juego de búsqueda y rescate personal en 3D, una aventura bastante bien lograda

Cannon Spike
Juego 3D poligonal muy bien logrado, peleas callejeras, disparas y todo sobre una patineta voladora, que mas quieres




Capcom Vs SNK 2 Millionaire Fighting 2001
Capcom Vs SNK Millennium Fight 2000 Pro
Juegos de peleas





Chaos Field
Shoot em up muy bonito, con muchos objetos en pantalla, es difícil reconocer cuales items son buenos o malos


















Charge'n Blast
Peleas contra bichos gigantes, algo tosco pero curioso





ChuChu Rocket
Curioso juego en el que vas colocando flechas para que unos ratones entren en tu cohete y unos gatos malos entren en el cohete de tus oponentes, esto les quita un tercio de sus ratones.



Cleopatra Fortune
Una especie de Tetris con piezas egipcias



Confidential Mission
Juego de espías, y misiones como 007, bastante bien hecho, no mates a civiles, pero a todo lo demás esta bien, jajaja



Cool Cool Toon
No me funciono en NullDc

Crazy Taxi 2
Busque pasaderos para si taxi y corra como loco por toda la ciudad para gaar mas dinero



Dance Dance Revolution

Daytona USA

Dead Or Alive 2



Death Crimson OX
Muy bonito y logrado, estilo árcade de disparos y muy alta calidad


Demolition Racer No Exit
Muy detallado y divertido, lo recomiendo


Dino Crisis

Draconus Cult Of The Wyrm



Evolution The World Of Sacred Device.cdi
F1 World Grand Prix.cdi
Fighting Force 2.cdi
Fighting Vipers 2.cdi
Frogger 2 Swampy's Revenge.cdi
Game Shark CDX.cdi
Grandia II Disc 1.cdi
Grandia II Disc 2.cdi
Guilty Gear X.cdi

Gun Bird 2

Muy bonito Shoot em up, vale la pena verlo en acción


Gundam Side Story 0079.cdi
Half Life Blue Shift.cdi
Heavy Metal Geomatrix.cdi
Hydro Thunder.cdi
Illbleed.cdi
Jeremy McGrath Supercross 2000.cdi
Jet Set Radio.cdi
Legacy Of Kain Soul Reaver.cdi
Maken X.cdi
Marvel Vs Capcom 2 New Age Of Heroes.cdi
MDK 2.cdi
Metropolis Street Racer.cdi
Mortal Kombat Gold.cdi
Namco Museum.cdi
NBA Hoopz.cdi
Plasma Sword Nightmare Of Bilstein.cdi
Pop 'N' Music.cdi
Pop 'N' Music 2.cdi
Power Stone.cdi
Power Stone 2.cdi
Project Justice.cdi
Psychic Force 2012.cdi
Psyvariar 2 The Will To Fabricate.cdi
Puyo Puyo.cdi
Quake III Arena.cdi
Radirgy.cdi
Rayman 2 The Great Escape.cdi
Ready 2 Rumble Round 2.cdi
Record Of Lodoss War.cdi
Reel Fishing Wild.cdi
Resident Evil Code Veronica Disk 1.cdi
Resident Evil Code Veronica Disk 2.cdi
Rez.cdi
Rival Schools 2 Board Game.cdi
Samba De Amigo.cdi
Samba De Amigo 2000.cdi
Shenmue Disk 1.cdi
Shenmue Disk 2.cdi
Shenmue Disk 3.cdi
Shenmue II Disk 1.cdi
Shenmue II Disk 2.cdi
Shenmue II Disk 3.cdi
Shenmue II Disk 4.cdi
Shikigami No Shiro 2.cdi
Skies Of Arcadia Disco 1.cdi
Skies Of Arcadia Disco 2.cdi
Sonic Adventure 2.cdi
Sonic Shuffle.cdi
Soul Calibur.cdi
Spawn In the Demon's Hand.cdi
Spider-Man.cdi
Star Wars Episode I  Racer.cdi
Star Wars Episode I Jedi Power Battles.cdi
Street Fighter III 3rd Strike.cdi
Super Puzzle Fighter 2.cdi
Sword Of The Berserk.cdi
The Last Blade 2.cdi
Times Talkers.cdi
TNN Motorsports Hardcore Heat.cdi
Tokyo Xtreme Racer 2.cdi
Trigger Heart Exelica.cdi
Trizeal.cdi
Ultimate Fighting Championship.cdi
Under Defeat.cdi
Unreal Tournament.cdi
Virtua Fighter 3tb.cdi
Virtua Tennis.cdi
Virtual On Oratorio Tangram.cdi
V-Rally 2.cdi
Zombie Revenge.cdi


Autor de juegos Richard Marks

Otro buen personaje con muchos juegos creados es: Richard Marks
En su pagina web nos muestra sus creaciones y cursos como

C-64 Game Development Tutorial en su antigua web ya casi perdida Aqui


La cual tratare de rescatar, aun no tengo el permiso, aun contactando al autor....

Después del permiso la traduciré

Juego de aventuras: Islandad venture


Richard Marks - www.ccpssolutions.com, May 16, 2009

Welcome to my Commodore 64 Game Development Tutorials!

I am going to be using the VICE x64 emulator, though you can use any Commodore 64 emulator or even the real hardware if you have it!
In this first article, we are going to cover the most basic of BASIC tasks...a bouncing ball demo.
The C64 after I just turned it on.

The Program Layout

We are going to layout our programs in the following manner:
  • Header
  • Program Init
  • Main Loop
  • Sub Routines
I want to be consistent in all my articles, so I have created a 9-line header that I will use to start all my programs in this series.
1 REM C-64 GAME DEVELOPMENT TUTORIALS
2 REM BY RICHARD MARKS
3 REM CCPSCEO@GMAIL.COM
4 REM WWW.CCPSSOLUTIONS.COM
5 REM *******************************
6 REM *
7 REM * THE BASIC BOUNCING BALL
8 REM *
9 REM *******************************
                
Another consistency that you will notice as I write these programs, is except for this header, all comments will be on an odd-numbered line, and all code will be written in line number increments of ten starting from 100.
Lets look at the code for the program initialization to see what I am talking about.
99 REM *** PROGRAM INIT ***
100 SC=1024:BG=6
110 BX=20:BY=11
120 DX=1:DY=1
130 POKE 53281,BG:PRINT "{SHIFT+CLR/HOME}"
                
You see that I add my program section comment on the line number preceding the first line of code (number 100 like I said before)
The lines after the section comment are increments of ten. 100, 110, 120, etc...

The Program Design

Now, lets talk a little about what our program will do.
Our demo is going to be very simple so that you can follow it easily.
Here is the program logic:
Flowchart for Program Logic
If you are not familiar with flowcharts (which is what that funny diagram above is) then lets go through it step by step.
Follow the arrows from each step...
  1. START This is where the program starts executing when the user RUNs the program.
  2. INITIALIZE PROGRAM VARIABLES This is where we give the initial values to the variables that we will use in our program.
  3. SET SCREEN COLORS We change the color of the screen and border here.
  4. CLEAR SCREEN We clear the entire screen of all characters at this point.
  5. RUN/STOP PRESSED? Here we have a dummy condition because our program will run indefinitely until the user hits the RUN/STOP key. This is a conditional block. If the result of the condition test is YES then we will follow the arrow down to the next step.
  6. END Here is where our program is no longer running. We are back in the C64 BASIC INTERPRETER at this point.
  7. DRAW BALL We get here if the RUN/STOP condition test result was NO. We draw the ball on the screen here.
  8. WAIT A SHORT TIME We are using a simple FOR-NEXT LOOP DELAY here.
  9. ERASE BALL We erase the ball from the screen to achieve the effect of motion.
  10. UPDATE BALL POSITION We add the ball delta values to the ball's position to obtain the new ball position.
  11. BALL X OUT OF BOUNDS? Another condition test. We want to know if the X position of the ball has reached either the left or right edges of the screen. If the result of the condition test is YES then we will follow the arrow down to the next step.
  12. INVERT X DELTA A simple inversion of our ball's delta X will make it seem to bounce off the edge.
  13. BALL Y OUT OF BOUNDS? Another condition test. We want to know if the Y position of the ball has reached either the top or bottom edges of the screen. If the result of the condition test is YES then we will follow the arrow down to the next step. If the result is NO, then we return to the RUN/STOP PRESSED? condition test to complete the loop.
  14. INVERT Y DELTA We get here in two ways. After the previous step finishes, or if the BALL X OUT OF BOUNDS? condition test result was NO. A simple inversion of our ball's delta Y will make it seem to bounce off the edge. After this step we return to the RUN/STOP PRESSED? condition test to complete the loop.
Well now wasn't that fun? Lets move on to the real fun stuff!

The Program Code

Alright here is what you have been waiting for!
If you were paying attention, you will know that first our program header will be written.
  1. Open up your Commodore 64 emulator
  2. Attach a disk image to it
  3. Type NEW to clear the program memory of the C64 if you haven't done so.
  4. Type in the program header lines
Here they are again for your convenience.
1 REM C-64 GAME DEVELOPMENT TUTORIALS
2 REM BY RICHARD MARKS
3 REM CCPSCEO@GMAIL.COM
4 REM WWW.CCPSSOLUTIONS.COM
5 REM *******************************
6 REM *
7 REM * THE BASIC BOUNCING BALL
8 REM *
9 REM *******************************
                
Next we type in the program init section
But, what goes there? Well, to figure this out, ask yourself "what do I need?".
My answers are below.
  • SC A variable to hold the screen memory address to make the code easier to read.
  • BG A variable to hold the color of the screen background.
  • BX A variable to hold the ball's horizontal screen position.
  • BY A variable to hold the ball's vertical screen position.
  • DX A variable to hold the ball's horizontal delta. (The velocity of the ball's motion along the X axis.)
  • DY A variable to hold the ball's vertical delta. (The velocity of the ball's motion along the Y axis.)
99 REM *** PROGRAM INIT ***
100 SC=1024:BG=6
110 BX=20:BY=11
120 DX=1:DY=1
                
Now, if you payed attention to the flowchat earlier, you will know that we next set our screen color and clear the screen.
To set the screen color, we POKE our background color state we stored in the BG variable into the proper memory address.
The VIC chip inside the C64 (the thing that provides our wonderful graphics) is located at the memory address 53248, and the register number for the screen background color is 33. Add 33 to 53248 and we get 53281. This is the proper memory address that we need to modify so that we can change the color of the screen.
Remember we set BG to have a value of 6? Well that is an index number of the color table..namely the color BLUE.
So that means we are going to clear the screen to blue. To do this, we just POKE our desired color table index number into the background color register of the VIC.
To clear the screen we are going to use a PRINT statement CONTROL CODE. You type PRINT then open the double-quote to enter QUOTE MODE, and press the SHIFT and HOME keys. You should see a little reverse-printed heart. close the double-quote to exit QUOTE MODE. When that code executes, the screen will be cleared.
130 POKE 53281,BG:PRINT "{SHIFT+CLR/HOME}"
Okay, now we begin the main loop of our program.
Drawing the ball. The Commodore 64 has some useful special characters in its ROM. One of which is a solid ball shape. The character value is 81. We are going to POKE that character on the screen at the calculated memory address.
How do we find the memory address to POKE our ball character to?
There is a very simple formula for figuring this out. P = X + Y * W
The screen memory is mapped in a linear fashion starting at memory address 1024. What this means is if you are starting at 1024 and moving right, when you go off the right edge of the screen you appear on the left edge, one row down at memory address 1064. (There are 40 character positions across the screen.)
So, we have our screen memory starting point stored in our SC variable, and our ball X position in BX and the Y position in BY, and we know there are 40 characters that make up one row of the screen. (This is the width of the screen.) So we have enough information to calculate the memory address.
The calculation is simple. For the first time that the code is called the memory address will be 1484. (SC (1024) + BX (20) + BY (11) * 40 = 1484)
149 REM *** MAIN LOOP ***
150 POKE SC+BX+BY*40, 81
                
Next we need to wait a short amount of time. I'm choosing to wait ten clock ticks.
160 FORW=1TO10:NEXT
                
To achieve the effect of motion, we erase the ball from its current position. To erase, we are just going to POKE a space (character 32) into the location.
170 POKE SC+BX+BY*40, 32
                
Updating the ball's position is very easy. Its BASIC addition for crying out loud!
180 BX=BX+DX
190 BY=BY+DY
                
Okay, we want our ball to bounce off the edges of the screen. To do this we just simple test the position and if we reach an edge, we inverse the delta for the axis.
200 IF BX <= 0 OR BX >= 39 THEN DX = -DX
210 IF BY <= 0 OR BY >= 24 THEN DY = -DY
                
Finally, we end our main loop by returning to the first line of our main loop code.
220 GOTO 150
                

Saving

Okay, I should have said this earlier, but SAVE OFTEN AND SAVE EARLY! I saved after I wrote every 2 lines of code in VICE.
To save your program, you need to have a writable disk image attached to your emulator (or a real writable disk in your Commodore 64 disk drive) and you type the following command:
SAVE "PROGRAM NAME", 8
                
Its VERY important that you remember to SAVE your work, otherwise you will lose your program when you turn off the C64 or quit the emulator!
And that is the end of this tutorial! Thank you for reading. If you have any questions or comments, please contact me.

Screenshots

Click on a thumbnail to view the full-sized image.
Load the saved program.
Loaded and ready to RUN.
Hey look! A ball! (Looks better in motion)
The full source after typing LIST in VICE.
All contents of this tutorial are © Copyright 2009, Richard Marks. All rights reserved. Permission to publish this article granted byRichard Marks to Mattias Gustavsson. This article may not be redistributed in any form without permission.Contact Richard Marks if you are interested in publishing this article on your site.





C-64 Game Development Tutorial #2

Richard Marks - www.ccpssolutions.com, May 18, 2009

Welcome to my Commodore 64 Game Development Tutorials!

I am going to be using the VICE x64 emulator, though you can use any Commodore 64 emulator or even the real hardware if you have it!
While it is not completely necessary to read the first article in the series before you read this one, I recommend that you do so in order to have a better understanding of the code.
In this article, we are going to add a paddle to our bouncing ball demo, that the user can move left and right with the keyboard.
The ball will not, however, bounce off the paddle in this demo. That will be covered in my next article.
Game Programming gets significantly more complex when you are writing for old hardware because there aren't any "libraries" of pre-written code that can ease any tasks. You need to plan everything in advance, otherwise you cannot get it written. The code is dependent on the line numbers that you use, resulting in a sort of code-lock that makes the task of making any changes once you start coding typically mean a complete rewrite. A clear and concise plan is required in order to write games on the C64 and I'm hoping that my article conveys this fact.

The Program Layout

In addition to the code from the first article, we will be using two sub routines in this demo.
Each sub routine will start at a line number starting with 1000 in increments of 200. That gives us 20 lines for each subroutine. That should be plenty of space to write a subroutine. If 20 lines is not enough, then you need to break up your subroutines more.

The Program Design

Now, lets talk a little about what our program will do.
Our demo is going to be very simple so that you can follow it easily.
Here is the program logic:
Flowchart for Program Logic
There are two sections to the flowchart above.
  1. The main program logic
  2. The subroutines: MOVE PADDLE LEFT (#1), and MOVE PADDLE RIGHT (#2)
Lets walk through the program's logic so that you have a better understanding of what you see above.
Start at the top at the START bubble and follow the arrows.
  1. START This is where the program starts executing when the user RUNs the program.
  2. INITIALIZE PROGRAM VARIABLES This is where we give the initial values to the variables that we will use in our program.
  3. SET SCREEN COLORS We change the color of the screen and border here.
  4. CLEAR SCREEN We clear the entire screen of all characters at this point.
  5. RUN/STOP PRESSED? Here we have a dummy condition because our program will run indefinitely until the user hits the RUN/STOP key. This is a conditional block. If the result of the condition test is YES then we will follow the arrow down to the next step.
  6. END Here is where our program is no longer running. We are back in the C64 BASIC INTERPRETER at this point.
  7. GET KEYBOARD INPUT We are going to scan the keyboard for a single keypress and store it in a variable.
  8. IS A KEY PRESSED? We need to see if the key that was pressed is our key for moving the paddle left, which is the Akey. If the result of this condition test is YES, then we JUMP to the #1 subroutine, otherwise we continue to the next step.
  9. IS D KEY PRESSED? We need to see if the key that was pressed is our key for moving the paddle right, which is the D key. If the result of this condition test is YES, then we JUMP to the #2 subroutine, otherwise we continue to the next step.
  10. A This is a JUMP TARGET which is just a marker to let us know that we will be returning to this point from somewhere else in the code. Just move to the next step, since no code is executed here.
  11. UPDATE BALL POSITION We add the ball delta values to the ball's position to obtain the new ball position.
  12. BALL X OUT OF BOUNDS? We want to know if the X position of the ball has reached either the left or right edges of the screen. If the result of this condition test is YES, then we will continue to the next step, otherwise we skip down to the following condition test.
  13. INVERT X DELTA To achieve the effect of bouncing the ball, we invert the value of the ball's horizontal motion delta X.
  14. BALL Y OUT OF BOUNDS? We want to know if the Y position of the ball has reached either the top or bottom edges of the screen. If the result of this condition test is YES, then we will continue to the next step, otherwise then we skip down to the DRAW BALL step.
  15. INVERT Y DELTA To achieve the effect of bouncing the ball, we invert the value of the ball's vertical motion delta Y.
  16. DRAW BALL We draw the character that will represent the ball on the screen when the code reaches this point of the execution.
  17. WAIT A SHORT TIME We are using a simple FOR-NEXT LOOP DELAY here.
  18. ERASE BALL We erase the ball from the screen to achieve the effect of motion.
  19. DRAW PADDLE We draw the characters that make up our paddle on the screen when the code reaches this point of execution. We JUMP back to the RUN/STOP PRESSED? condition test to complete our loop and the code will execute again from that point.
The MOVE PADDLE LEFT (#1) subroutine logic is as follows:
  1. PADDLE X-1+W/2 OUT OF BOUNDS? We test to see if the position left of the paddle reaches the left edge of the screen. If the result of this condition test is YES, then we RETURN to our Jump Target A. If the result of this condition test is NO, then we continue down to the next step.
  2. DECREMENT PADDLE X We decrease the value of the variable that holds the paddle's X position.
  3. ERASE RIGHT OF PADDLE When we move the paddle, there will be a ghost character on the right side of the paddle, we erase this character before we RETURN to our Jump Target A.
The MOVE PADDLE RIGHT (#2) subroutine logic is the same as the #1 subroutine except its reversed as you will see below:
  1. PADDLE X+1+W/2 OUT OF BOUNDS? We test to see if the position right of the paddle reaches the right edge of the screen. If the result of this condition test is YES, then we RETURN to our Jump Target A. If the result of this condition test is NO, then we continue down to the next step.
  2. INCREMENT PADDLE X We increase the value of the variable that holds the paddle's X position.
  3. ERASE LEFT OF PADDLE When we move the paddle, there will be a ghost character on the left side of the paddle, we erase this character before we RETURN to our Jump Target A.
As you can see, there isn't anything really complex going on here. Lets get on with the code next!

The Program Code

I said that I was going to reuse the code from the first article, however I'm not simply loading the old program and adding new lines. I am writing everything over from scratch because we need to add more variables, do more initialization, and the line numbers are going to change quite a bit.
The first 9 lines will remain the same except for line #7 which will hold a new comment for our program name. The header is below:
1 REM C-64 GAME DEVELOPMENT TUTORIALS
2 REM BY RICHARD MARKS
3 REM CCPSCEO@GMAIL.COM
4 REM WWW.CCPSSOLUTIONS.COM
5 REM *******************************
6 REM *
7 REM * ENTER THE PADDLE
8 REM *
9 REM *******************************
  
Next we type in the program init section
Our program will require several new variables.
I should have mentioned in the first article that variable names can be only one, or two characters in length, made up of only alpha-numeric characters A-Z and 0-9. Additionally, STRING variables are suffixed with a dollar sign. Such as A$
There are a few reserved variables that you may not define, since they are used for special purposes.
  • ST I/O status.
  • TI Every 1/60th of a second this variable will be updated. When you turn on the C64, this value starts at 0.
  • TI$ Automatically updated by the C64; This string holds a clock in the form of three pairs of numbers to represent the hours, minutes, and seconds.
We are not going to use either of these in our program, so I will not explain their usage in depth.
Moving on, lets see what variables will our program require.
MEMORY ADDRESS POINTER VARIABLES
We will be POKE-ing and PEEK-ing different memory locations, and to keep from retyping the memory addresses over and over, we define variables that hold the starting address of the hardware we need to access.
  • M1 A variable to hold the screen memory address.
  • M2 A variable to hold the color memory address.
  • M3 A variable to hold the screen background color register memory address.
  • M4 A variable to hold the screen border color register memory address.
Note: By default, the screen memory address space starts at 1024, and the color memory address space starts at 55296.
The screen is 40x25 (1000) characters in size. That is, forty characters across and 25 down. Every character screen cell has two attributes that are located in two different places in memory. The character value is in screen memory, and the color is in color memory. By POKE-ing values into the screen memory (1024 - 2023) we will see the specified character displayed on the screen, and when we POKE values into the color memory (55296 - 56295) we will change the color of the screen cell we specified.
The values that can be POKEd into screen memory are 0 - 255. The values that you can POKE into the color memory are 0 - 15, each value corresponding to the following colors:
  1. BLACK
  2. WHITE
  3. RED
  4. CYAN
  5. PURPLE
  6. GREEN
  7. BLUE
  8. YELLOW
  9. ORANGE
  10. BROWN
  11. 10 LIGHT RED
  12. 11 DARK GRAY
  13. 12 GRAY
  14. 13 LIGHT GREEN
  15. 14 LIGHT BLUE
  16. 15 LIGHT GRAY
If you POKE values larger than 15 into color memory, you will cycle through the color table again. Eg 16 is BLACK, 17 is WHITE, etc..
COLOR VARIABLES
These variables will let us change the colors we use easily.
  • C1 A variable to hold the color of the screen background.
  • C2 A variable to hold the color of the screen border.
  • C3 A variable to hold the color of the ball.
  • C4 A variable to hold the color of the paddle.
GENERAL PURPOSE / SUBROUTINE VARIABLES
These variables will serve different purposes depending on when they are used. They are used by subroutines.
  • K$ A variable to hold the key that was last pressed.
BALL OBJECT VARIABLES
These variables define the properties of our ball object.
  • BX A variable to hold the ball's horizontal screen position.
  • BY A variable to hold the ball's vertical screen position.
  • B1 A variable to hold the ball's horizontal delta. (The velocity of the ball's motion along the X axis.)
  • B2 A variable to hold the ball's vertical delta. (The velocity of the ball's motion along the Y axis.)
PADDLE OBJECT VARIABLES
These variables define the properties of our paddle object.
  • PX A variable to hold the paddle's horizontal screen position.
  • PY A variable to hold the paddle's vertical screen position.
  • PW A variable to hold the paddle's width in characters.
We need to initialize our program's variables now. Lets make our screen green, the border light green, our ball white, and our paddle black. We are going to create our paddle using 3 special C64 characters. The paddle width will be 5. We will start our ball near the center of the screen, and the paddle will start in the bottom center of the screen. The paddle position corresponds to the left edge of the paddle. The ball should start moving down and to the right. Using this knowledge, we can initialize all our program's variables.
99 REM *** PROGRAM INIT ***
100 M1=1024:M2=55296:M3=53281:M4=53280
110 C1=5:C2=13:C3=1:C4=0
120 BX=20:BY=11:B1=1:B2=1
130 PX=20:PY=24:PW=5
  
Clearing the screen and setting our screen colors is nearly the same as the bouncing ball demo code. We just need to use our new memory address pointer variables and color variables.
140 POKE M3,C1:POKE M4,C2:PRINT "{SHIFT+CLR/HOME}"
  
Okay, now we begin the main loop of our program.
Referring to the flowchart that I showed you earlier, we see that the first thing that we must do is get the keyboard input. We do this using the GET BASIC statement. It allows one to get a single character of data from the keyboard.
199 REM *** MAIN LOOP ***
200 GET K$
  
That was easy... Right? Okay, lets get the conditions out the way.
210 IF K$ = "A" THEN GOTO 1000
220 IF K$ = "D" THEN GOTO 1200
  
Next we update the ball position like our flowchart tells us. And then we handle the ball bouncing condition tests.
230 BX=BX+B1:BY=BY+B2
240 IF BX <= 0 OR BX >= 39 THEN B1 = -B1
250 IF BY <= 0 OR BY >= 24 THEN B2 = -B2
  
Lets draw the ball, wait five clock ticks, and erase the ball.
This line looks a little complex. Let me break it down for you.
  1. A1=M1+BX+BY*40 We calculate the memory address in screen memory space that the ball will be drawn in, and save the address in the A1 variable.
  2. POKE A1+M2-M1,C3 We POKE the ball color into color memory space at the calculated address that we get by adding the color memory address to our A1 variable and subtracting the screen memory address.
  3. POKE A1,81 We POKE the ball character into screen memory space at the address we calculated before.
  4. FOR W = 1 TO 5:NEXT We wait for five clock ticks using a simple FOR-NEXT LOOP construct.
  5. POKE A1,32 We POKE an empty space character into screen memory space to erase the ball.
260 A1=M1+BX+BY*40:POKE A1+M2-M1,C3:POKE A1,81:FOR W = 1 TO 5:NEXT:POKE A1,32
  
We now need to draw the paddle like our flowchart tells us to. This is a little more complex than the ball drawing code since our paddle is made of five characters and not one. I guess I should explain the fun stuff below so you are not scratching your head wondering.
  1. A1=M1+PX+PY*40 We add the screen memory address, the paddle X position, and the paddle Y position and multiply the whole shbang by 40 to get the proper memory address for the left side of the paddle, and save the result in the A1 variable.
  2. POKE A1,85 We POKE the character for the paddle's left side to draw it on the screen.
  3. POKE A1+PW,73 We POKE the character for the paddle's right side to draw it on the screen.
  4. FOR A2 = A1+1 TO A1+(PW-1):POKE A2,67:NEXT We POKE the character that makes up the paddle center using a FOR-NEXT LOOP.
  5. A2=A1+M2-M1 We calculate the color memory address for the paddle's left side.
  6. FOR A3 = A2-1 TO A2+PW:POKE A3,C4:NEXT We loop across the entire paddle and color it with our paddle color.
270 A1=M1+PX+PY*40
280 POKE A1,85:POKE A1+PW,73:FOR A2 = A1+1 TO A1+(PW-1):POKE A2,67:NEXT
290 A2=A1+M2-M1:FOR A3 = A2-1 TO A2+PW:POKE A3,C4:NEXT
  
Finally, we end our main loop by returning to the first line of our main loop code.
300 GOTO 200
  
Now we need to write the subroutines. Remember that we are starting subroutines at line 1000, and that we skip 200 line numbers between each subroutine.
Moving to the left
999 REM ** MOVE PADDLE LEFT SUB
1000 X1=PX-1
1010 IF X1 < 0 THEN GOTO 230
1020 PX=PX-1
1030 POKE M1+PX+PW+1+PY*40,32: GOTO 230
  
Moving to the right
1199 REM ** MOVE PADDLE RIGHT SUB
1200 X1=PX+PW+1
1210 IF X1 > 39 THEN GOTO 230
1220 PX=PX+1
1230 X2=X1-(PW+1)
1240 POKE M1+X2+PY*40,32:GOTO 230
  
And that is the end of this tutorial! Thank you for reading. If you have any questions or comments, please contact me.

Full Source

I've provided the full source below to make it easier for you to see the program as a whole.
1 REM C-64 GAME DEVELOPMENT TUTORIALS
2 REM BY RICHARD MARKS
3 REM CCPSCEO@GMAIL.COM
4 REM WWW.CCPSSOLUTIONS.COM
5 REM *******************************
6 REM *
7 REM * ENTER THE PADDLE
8 REM *
9 REM *******************************
99 REM *** PROGRAM INIT ***
100 M1=1024:M2=55296:M3=53281:M4=53280
110 C1=5:C2=13:C3=1:C4=0
120 BX=20:BY=11:B1=1:B2=1
130 PX=20:PY=24:PW=5
140 POKE M3,C1:POKE M4,C2:PRINT "{SHIFT+CLR/HOME}"
199 REM *** MAIN LOOP ***
200 GET K$
210 IF K$ = "A" THEN GOTO 1000
220 IF K$ = "D" THEN GOTO 1200
230 BX=BX+B1:BY=BY+B2
240 IF BX <= 0 OR BX >= 39 THEN B1 = -B1
250 IF BY <= 0 OR BY >= 24 THEN B2 = -B2
260 A1=M1+BX+BY*40:POKE A1+M2-M1,C3:POKE A1,81:FOR W = 1 TO 5:NEXT:POKE A1,32
270 A1=M1+PX+PY*40
280 POKE A1,85:POKE A1+PW,73:FOR A2 = A1+1 TO A1+(PW-1):POKE A2,67:NEXT
290 A2=A1+M2-M1:FOR A3 = A2-1 TO A2+PW:POKE A3,C4:NEXT
300 GOTO 200
999 REM ** MOVE PADDLE LEFT SUB
1000 X1=PX-1
1010 IF X1 < 0 THEN GOTO 230
1020 PX=PX-1
1030 POKE M1+PX+PW+1+PY*40,32: GOTO 230
1199 REM ** MOVE PADDLE RIGHT SUB
1200 X1=PX+PW+1
1210 IF X1 > 39 THEN GOTO 230
1220 PX=PX+1
1230 X2=X1-(PW+1)
1240 POKE M1+X2+PY*40,32:GOTO 230
  

Screenshots

Click on a thumbnail to view the full-sized image.
Loading in the code after I've saved.
The code running.
The first section of code..
The second section of code..
The third section of code..

All contents of this tutorial are © Copyright 2009, Richard Marks. All rights reserved. Permission to publish this article granted byRichard Marks to Mattias Gustavsson. This article may not be redistributed in any form without permission.Contact Richard Marks if you are interested in publishing this article on your site.