Tag Archives: hardware

Made a Meatloaf device for C64

Awesome opensource project

https://github.com/idolpx/meatloaf-specialty/tree/main

  • Emulates a floppy drive: Meatloaf plugs into the Commodore 64’s IEC serial port and acts like a virtual floppy drive. This allows you to load software and data stored on its internal flash memory, sd card, or stream it via WiFi using various protocols from servers all over the world.
  • Supports multiple virtual drives: Unlike a single floppy drive, Meatloaf can be configured to emulate up to 26 virtual drives (IDs 4-30). Each virtual drive can have a different disk image loaded, essentially offering the equivalent of having thousands of floppies connected to your C64.
  • Supports additional virtual device types: Printers, a network interface, and more.
  • Connects to the internet: Meatloaf also functions as a WiFi modem, enabling your Commodore 64 to connect to Telnet BBS (bulletin board systems) for communication and sharing information.

https://meatloaf.cc/sc/s/shortcodes.php

Load a prg using a url

LOAD"HTTP://C64.ORG/GAMES_AZ/H/H.E.R.O.PRG",8

Or from a D64 image on your own Windows/Samba server (all known CBM image formats supported):

LOAD"SMB://STORAGE/C64/FAVORITES/PIRATES_A.D64/*",8

Load a random game from the internet

LOAD"ML:ARCADE*",8	

Reverse engineering Newton wars, giving it my own twist.

Saw a cool game a while ago, and found some old code.
There was no schematic, so I had to reverse engineer it using the Arduino code.
This one uses a Micro Pro.

Build a working version, now I can use this as base to create other games.
But first i’m going to rebuild it so it can use Wifi and uses a Lipo Battery. Making it usable without wires.

  • Rotary – set angle/speed (Press resets)
  • Blue – toggle angle or speed ( was rotary press )
  • Green – select digit to change
  • Red – Fire
  • Led – not completely working yet, shows color of player
    Wil be changed to addressable leds with more functions
    (Player color, energy warning and more)

Next to do:

  • Build a Wifi version with Lipo
  • Build permanent version in a case
  • Build 2nd 3th or more controllers
  • Create own games

Bornhack 2023 NFC Badge Display hack

Last week I bought an old Bornhack Badge. I thought it needed a display.

Using a SSD1306 display, and Circuitpython I made this.

( Wooded thingy contains an RFID chip ( Part of my player ))

Library and files needed:

  • font5x8.bin in root of filesystem ( just google for this file )
  • copy of adafruit_framebuf.mpy in /lib
  • copy of adafruit_ssd1306.mpy in /lib

Code: (midway some pixel examples, just uncomment)

import board
from time import sleep
import busio 
from PN7150 import PN7150
import adafruit_ssd1306
import math
import adafruit_framebuf


if True:
    # Fast 400KHz I2C
    i2c = busio.I2C(board.SCL, board.SDA, frequency = 400000)
else:
    # Regular 100kHz I2C
    i2c = board.I2C()


WIDTH = 32
HEIGHT = 8

buffer = bytearray(round(WIDTH * math.ceil(HEIGHT / 8)))
fb = adafruit_framebuf.FrameBuffer(
    buffer, WIDTH, HEIGHT, buf_format=adafruit_framebuf.MVLSB
)


nfc = PN7150(i2c, board.IRQ, board.VEN)

display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c,addr=0x3c)

assert nfc.connect()
print("Connected.")

assert nfc.modeRW()
print("Switched to read/write mode.")

display.fill(0)

display.show()

#display.fill(0)
#display.text('Hello', 0, 0, 1 )
#display.text('World', 0, 10, 1)
#display.show()
# Set a pixel in the origin 0,0 position.
#display.pixel(0, 0, 1)
# Set a pixel in the middle 64, 16 position.
#display.pixel(64, 16, 1)
# Set a pixel in the opposite 127, 31 position.
#display.pixel(127, 31, 1)
#display.show()

while True:
    display.fill(0)
    display.text('Waiting for card', 0, 0, 1 )
    display.show()

    assert nfc.startDiscoveryRW()

    print("Waiting for card..")
    card = nfc.waitForCard()
    assert nfc.stopDiscovery()

    print("ID: {}".format(card.nfcid1()))
    id = card.nfcid1()
    display.text(id, 0, 10, 1 )
    display.show()

    sleep(0.5)

Not sure about display i2c address? Use below code

import time
import board
import busio

# List of potential I2C busses
ALL_I2C = ("board.I2C()",)

# Determine which busses are valid
found_i2c = []
for name in ALL_I2C:
    try:
        print("Checking {}...".format(name), end="")
        bus = eval(name)
        bus.unlock()
        found_i2c.append((name, bus))
        print("ADDED.")
    except Exception as e:
        print("SKIPPED:", e)

# Scan valid busses
if len(found_i2c):
    print("-" * 40)
    print("I2C SCAN")
    print("-" * 40)
    while True:
        for bus_info in found_i2c:
            name = bus_info[0]
            bus = bus_info[1]

            while not bus.try_lock():
                pass

            print(
                name,
                "addresses found:",
                [hex(device_address) for device_address in bus.scan()],
            )

            bus.unlock()

        time.sleep(2)
else:
    print("No valid I2C bus found.")

Keyboard switcher part 2

I’ve connected the rotary encoder directly to the zero.
Although many websites state that you need pull-up resistors, there is no need. Just use the internal pull-up resistors in the Pi.

Example code

        GPIO.setmode(GPIO.BCM)					# Use BCM mode
        GPIO.setup(self.24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.setup(self.25, GPIO.IN, pull_up_down=GPIO.PUD_UP)
NOTE: Between 24 and 25 is a GND connection

Besides USB HID below XT, C64 and Amiga connectors will be emulated

PCBs !

Got my new PCBs in.

My Bus Manipulator, Backplane for 6502, and C64 PLA replacement.

I’m selling the leftover PCBs if you are interested.

These are not the final versions.
They should work, but they lack holes for stand-offs or feet.

Example setups for the backplane.
Using a flatcable or direct connection to my 6502 SBC.

The backplane was designed to be chained together.
(Horizontal female – male connection)

The vertical cards I’ve planned to make are:

  • ACIA – Serial Interface
  • Sound Card (SID/AY-2-8910)
  • External Display
  • ?

Keyboard switch part 1

Testing the first keyboard. It is the 8085-SDK hex matrix keyboard.

It is running on a Raspberry Pi Zero 2, without X server.
So the images are displayed using the framebuffer.
Also the touch data is read using evdev and the raw devices.

Todo:

  • HID part
  • Add a rotary button for the selection of the different Keyboard Layouts
  • Improvement keyboard matrix calculation to find out which key is being pressed.
  • Code to control AT/PS2 computers directly using GPIO pins
  • Add a controller to use Raw controlling of matrix pins ( 6502 C64 hardware for example )

Bash test and configuring the OS for testing.

cat <<EOF >> /boot/config.txt
hdmi_group=2
hdmi_mode=87
hdmi_timings=400 0 100 10 140 1280 10 20 20 2 0 0 0 60 0 43000000 3
display_rotate=3
EOF

# Image testing
apt-get install fbi
sudo fbi -d /dev/fb0 -T 1 8085.png  -a --noverbose

apt-get install python3-evdev python3-uinput evtest
evtest

First simple python test

import select
from math import floor
import sys
slot = 0

keysname=[["F","E","D","C","vect-int","reset"],
          ["B","A","9","8","GO","Single-Step"],
          ["7","6","5","4","Exam-reg","Subst-mem"],
          ["3","2","1","0","Exec","Next"],
          ]
keysnames=[["F","E","D","C","vect-int","reset"],
          ["B","A","L","H","GO","Single-Step"],
          ["PCL","PCH","SPL","SPH","Exam-reg","Subst-mem"],
          ["3","2","1","0",".",","],
          ]

for path in evdev.list_devices():
    device = evdev.InputDevice(path)
    if evdev.ecodes.EV_ABS in device.capabilities():
        break
else:
    sys.stderr.write('Failed to find the touchscreen.\n')
    sys.exit(1)

while True:
    r, w, x = select.select([device.fd], [], [])

    id_ = -1
    x = y = 0

    for event in device.read():

        if event.code == event.value == 0:
           if id_ != -1:
                yy = floor(( x - 600 ) / 700)
                xx = floor(( y - 1377 ) / 226)
                if yy < 4 and yy >=0 and xx < 6 and xx >= 00:
                     if slot == 1:
                         print(keysnames[yy][xx])
                     else:
                         print(keysname[yy][xx])

        elif event.code == ABS_MT_TRACKING_ID:
            id_ = event.value
        elif event.code == ABS_MT_SLOT:
            slot = event.value
        elif event.code == ABS_MT_POSITION_X:
            x = event.value
        elif event.code == ABS_MT_POSITION_Y:
            y = event.value

I came up with a simple matrix calculation

Pressing the 4 corner keys gave me x and y.
I took averages for min and max reading.
I don’t need pixel-perfect reading, and I noticed values between 960 and 3080 vertically.
We want 960 – 3080 into 4 blocks, but the middle should start @ 960.

So 3080/3 = about 700
700 / 2 = 350
block 1 starts 350 sooner than 960 is ~ 600
Upper key y coords = 600-> + 700
Next is 1300 -> + 700
converting to whole numbers using floor gives me:
floor(( y – 600 ) / 700)
NOTE: My x and y are rotated

Example using coordinates
1600, 1600
floor(( 1600 – 600 ) / 700) = floor(1,4…) = 1st row
(from row 0,1,2,3)

C64 Assembly, KiCad PCB design, and Keyboard Layout switcher

I’ve been busy programming Python and NodeRed for a client.
But these are the things I’ve done in the last days.

C64 Assembly:
Breaking borders, using sprites and multicolor font intro.

It does not look impressive, but I’ve learned a lot.
Found a new way (for me) to open borders and change border colours on predefined raster lines.
Sources will be posted.

KiCad tutorial, posted on YT also because I could not find many resources about the subject online. Maybe it’s helpful

Video editing using Kdenlive.

Edit: Even faster, use Netlabels, no need to join pins.
Press L (uppercase) select pin 1, name 1.
Press and hold insert until all pins named.
Copy paste socket 5 times and goto your PCB tab.

This movie is about creating a backplane for a 6502 SBC I’m building.
It is real-time and below 4 minutes.

Multi Keyboard

My small multitouch screen came in.
This is for my previously mentioned multi-computer case.

It is going to show multiple keyboard layouts for different systems.
(See previous posts about this)

Waveshare display, Raspberry Zero as HID device, using USB and pin emulated keyboards. (c64 matrix, AT (DIN) keyboard, ps2 keyboard)

Some example screens

Vic-20
Photo-realistic
Petscii C64
Another C64

I’m also going to make a layout like the keyboards on my 8085

64×64 Etch a Sketch

In the past I made a Etch a Sketch with my lasercutter.

Using two rotary encoders and the 64×64 matrix display I recently bought, I made a drawing thingy.
Like a Etch a Sketch.

Some Circuit Python code.
Now I have to fix an out of memory issue using below.
And make a colour selection button??? 🙂

import time
import board
import displayio
import math
import vectorio
import rgbmatrix
import framebufferio
import array
import bitmaptools

import rotaryio
import board

encoder1 = rotaryio.IncrementalEncoder(board.GP27, board.GP26)
encoder2 = rotaryio.IncrementalEncoder(board.GP18, board.GP19)

last_position1 = 0
last_position2 = 0

# Release any existing displays
displayio.release_displays()

# --- Matrix Properties ---
DISPLAY_WIDTH = 64
DISPLAY_HEIGHT = 64

# --- Matrix setup ---
BIT_DEPTH = 2
matrix = rgbmatrix.RGBMatrix(
    width=64, bit_depth=2, height=64,
    rgb_pins=[board.GP0, board.GP1, board.GP2, board.GP3, board.GP4, board.GP5],
    addr_pins=[board.GP6, board.GP7, board.GP8, board.GP9, board.GP22],
    clock_pin=board.GP10, latch_pin=board.GP12, output_enable_pin=board.GP13)
colrs = 13
display = framebufferio.FramebufferDisplay(matrix, auto_refresh=True)
b1 = displayio.Bitmap(display.width, display.height, colrs )
palette = displayio.Palette(colrs )
palette[0] = 0x000000  # black
palette[1] = 0x964B00  # brown (light yellow) 
palette[2] = 0x00FFFF  # cyan
palette[3] = 0x850101  # deep red 
palette[4] = 0x7F00FF  # violet
palette[5] = 0xC46210  # orange
palette[6] = 0x3D9140  # Cobalt green  
palette[7] = 0x004225  # british racing green 
palette[8] = 0x8B008B  # dark magenta 
palette[9] = 0x1F75FE  # crayola  blue
palette[10] =0x00308F  # air force blue US air force    
palette[11] =0xBF00FF  # electric purple 
palette[12] =0x08E8DE  # turquoise
g1 = displayio.Group(scale=1)
display.root_group = g1 

bmp = displayio.Bitmap(64,64, 2)

tilegrid = displayio.TileGrid(bitmap=bmp, pixel_shader=palette)
g1.append(tilegrid)
display.auto_refresh = True

tilegrid = displayio.TileGrid(bitmap=bmp, pixel_shader=palette)
while True:
        position1 = encoder1.position
        if last_position1 is None or position1 != last_position1:

            if position1 > last_position1:
                position1 = position1 + 1
            if position1 < last_position1:
                position1 = position1 - 1
            if position1 < 0:
                position1 = 0
            last_position1 = position1
        position2 = encoder2.position
        if last_position2 is None or position2 != last_position2:
            if position2 > last_position2:
                position2 = position2 + 1
            if position2 > last_position2:
                position2 = position2 - 1
            if position2 < 0:
                position2 = 0
            last_position2 = position2

        bmp[position1,position2]=1
        tilegrid = displayio.TileGrid(bitmap=bmp, pixel_shader=palette)
        g1.append(tilegrid)
        display.auto_refresh = True