Skip to content

Commit

Permalink
C64 version
Browse files Browse the repository at this point in the history
  • Loading branch information
gameblabla committed Apr 3, 2023
1 parent 2815eb7 commit 1d40719
Show file tree
Hide file tree
Showing 81 changed files with 3,850 additions and 0 deletions.
2 changes: 2 additions & 0 deletions C64/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.elf
*.prg
Binary file added C64/DaDither.exe
Binary file not shown.
Binary file added C64/Ohmy_whatdowehave.wav
Binary file not shown.
11 changes: 11 additions & 0 deletions C64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright Infringement C64

This is a port for the C64, but it's somewhat basic as the whole game has to stay in RAM.
I decided to do it like so in the case i want to convert this to a cartridge game.
There is a provided PRG2CRT version but it's not designed to take advantage of the mapper, it's just a straight conversion.

The C64 version was quite challenging to do, and ironically the biggest challenge on this is certainly the RAM.
I initially wanted to use compression with lzsa for still frames.
However even if i had done that, i would have only saved 4kb as the animated frames have to be uncompressed
as the C64's CPU is barely fast enough for B&W graphics.

Binary file added C64/bakura-g.koa
Binary file not shown.
630 changes: 630 additions & 0 deletions C64/bakura.h

Large diffs are not rendered by default.

Binary file added C64/bakura.koa
Binary file not shown.
Binary file added C64/bakura_bitmap.bin
Binary file not shown.
Binary file added C64/bakura_bitmapc.bin
Binary file not shown.
3 changes: 3 additions & 0 deletions C64/bakura_c.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
����������������������������������������������������˼������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������˼����˺�)��˼)���������˼�������ϫ�/��˲,����������������������������������������������򫨯�������������������������������������������˼���Ͽ��������������ϼ�����������ϼ�������������������������������������ϼ���������˼򼼶�������˼�����������������˼����������������������������˼��kkkk�kkk�kk��˿���{ghk��ikkkkkkkk�koo�����k                                                  
                
  
Binary file added C64/bakura_c64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added C64/bakura_color.bin
Binary file not shown.
Binary file added C64/bakura_conv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added C64/bakura_y.koa
Binary file not shown.
Binary file added C64/c64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions C64/convert_4bit_pcm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

#14489
#15040

if [ "$#" -ne 3 ]; then
echo "Usage: $0 input_file output_file sample_rate"
exit 1
fi

input_file="$1"
output_file="$2"
sample_rate="$3"

temp_file="temp_8bit.wav"

# Downconvert the input file with sox
sox "$input_file" -c 1 -r "$sample_rate" "$temp_file"

# Convert the 8-bit downconverted file to 4-bit PCM
python convert_8bit_to_4bit.py "$temp_file" "$output_file"

# Remove the temporary file
rm "$temp_file"
33 changes: 33 additions & 0 deletions C64/convert_8bit_to_4bit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
import wave
import numpy as np

def convert_8bit_to_4bit(input_file, output_file):
with wave.open(input_file, 'rb') as wav_in:
params = wav_in.getparams()
n_channels, sampwidth, framerate, n_frames = params[:4]

if n_channels != 1:
raise ValueError('The input WAV file should be mono')

audio_data = wav_in.readframes(n_frames)
audio_data = np.frombuffer(audio_data, dtype=np.uint8)

# Normalize to 4-bit
audio_data = audio_data >> 4

# Pack two 4-bit samples into one byte
packed_data = np.zeros(n_frames // 2, dtype=np.uint8)
packed_data = (audio_data[::2] << 4) | audio_data[1::2]

with open(output_file, 'wb') as pcm_out:
pcm_out.write(packed_data.tobytes())

if __name__ == '__main__':
if len(sys.argv) < 3:
print(f'Usage: python {sys.argv[0]} input_file output_file')
sys.exit(1)
input_file = sys.argv[1]
output_file = sys.argv[2]

convert_8bit_to_4bit(input_file, output_file)
3 changes: 3 additions & 0 deletions C64/convert_image_to_h.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
head -c 8000 "$1" > "$2"_bitmap.bin
tail -c +8001 "$1" > "$2"_color.bin
6 changes: 6 additions & 0 deletions C64/convert_image_to_h_half.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
head -c 8000 "$1" > temp_bitmap.bin
tail -c +8001 "$1" > temp_color.bin

dd if=temp_bitmap.bin of="$2"_bitmap.bin bs=1 count=6400
dd if=temp_color.bin of="$2"_color.bin bs=1 count=1600
7 changes: 7 additions & 0 deletions C64/convert_wav.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
python wav2c64pcm.py whatdowehave_4000.wav what.pcm
python wav2c64pcm.py rikuto_4000.wav rikuto.pcm
python wav2c64pcm.py fun_4000.wav fun.pcm

bin2c what.pcm what_pcm.h what_pcmdata
bin2c rikuto.pcm rikuto_pcm.h rikuto_pcmdata
bin2c fun.pcm fun_pcm.h fun_pcmdata
Binary file added C64/convertron-1_2-210823_164146-linux-x86_64
Binary file not shown.
1 change: 1 addition & 0 deletions C64/convertron3000
Submodule convertron3000 added at 2db3b4
Binary file added C64/decline_4000.wav
Binary file not shown.
168 changes: 168 additions & 0 deletions C64/disp.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
.global Draw_firstframe
.global Draw_firstframe_color
.global Draw_frame2
.global Draw_frame3
.global Draw_frame4
.global Draw_Bakura

baku_bin: .incbin "bakura_bitmapc.bin"
baku_c: .incbin "bakura_c.bin"

source: .incbin "frame1_bitmap.bin"
source1: .incbin "frame1_color.bin"
source2: .incbin "frame2_bitmap.bin"
source3: .incbin "frame3_bitmap.bin"
source4: .incbin "frame4_bitmap.bin"
;source2c: .incbin "frame2_color.bin"
;source3c: .incbin "frame3_color.bin"
;source4c: .incbin "frame4_color.bin"

len = 6400
len1 = 1600

from = $fb
to = $fd
tmpx = $a6

Draw_Bakura:

lda #<baku_c
sta from
lda #>baku_c
sta from+1
lda #<$c000
sta to
lda #>$c000
sta to+1

ldy #0
ldx #>len1
jsr fast_memcpy
lda #<baku_bin
sta from
lda #>baku_bin
sta from+1
lda #<$e000
sta to
lda #>$e000
sta to+1
ldy #0
ldx #>len
jsr fast_memcpy
rts

Draw_firstframe_color:

lda #<source1
sta from
lda #>source1
sta from+1
lda #<$c000
sta to
lda #>$c000
sta to+1

ldy #0
ldx #>len1
jsr fast_memcpy
rts
Draw_firstframe:


lda #<source
sta from
lda #>source
sta from+1
lda #<$e000
sta to
lda #>$e000
sta to+1
ldy #0
ldx #>len
jsr fast_memcpy

rts

Draw_frame2:


lda #<source2
sta from
lda #>source2
sta from+1

lda #<$e000
sta to
lda #>$e000
sta to+1
ldy #0
ldx #>len
jsr fast_memcpy

rts
Draw_frame3:


lda #<source3
sta from
lda #>source3
sta from+1

lda #<$e000
sta to
lda #>$e000
sta to+1
ldy #0
ldx #>len
jsr fast_memcpy

rts
Draw_frame4:

lda #<source4
sta from
lda #>source4
sta from+1

lda #<$e000
sta to
lda #>$e000
sta to+1
ldy #0
ldx #>len
jsr fast_memcpy

rts
fast_memcpy:

beq remain
next: lda (from),y
sta (to),y
iny
bne next
inc from+1
inc to+1
dex
bne next
remain: ldx #<len
beq done
nextr: lda (from),y
sta (to),y
;iny
dex
bne nextr
done: rts
44 changes: 44 additions & 0 deletions C64/font.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const unsigned char font[640] = {
0x05, 0x16, 0x16, 0x16, 0x16, 0x16, 0x05, 0x00, 0x40, 0x50, 0x50, 0x50, 0x50, 0x50, 0x40, 0x00,
0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00,
0x05, 0x16, 0x00, 0x05, 0x14, 0x16, 0x15, 0x00, 0x40, 0x50, 0x50, 0x40, 0x00, 0x50, 0x50, 0x00,
0x05, 0x16, 0x00, 0x05, 0x00, 0x16, 0x05, 0x00, 0x40, 0x50, 0x50, 0x40, 0x50, 0x50, 0x40, 0x00,
0x16, 0x16, 0x16, 0x15, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00,
0x15, 0x16, 0x14, 0x15, 0x00, 0x16, 0x05, 0x00, 0x50, 0x50, 0x00, 0x40, 0x50, 0x50, 0x40, 0x00,
0x05, 0x16, 0x14, 0x15, 0x16, 0x16, 0x05, 0x00, 0x40, 0x50, 0x00, 0x40, 0x50, 0x50, 0x40, 0x00,
0x15, 0x16, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00,
0x05, 0x16, 0x16, 0x05, 0x16, 0x16, 0x05, 0x00, 0x40, 0x50, 0x50, 0x40, 0x50, 0x50, 0x40, 0x00,
0x05, 0x16, 0x16, 0x05, 0x00, 0x16, 0x05, 0x00, 0x40, 0x50, 0x50, 0x50, 0x50, 0x50, 0x40, 0x00,
0x05, 0x14, 0x14, 0x15, 0x14, 0x14, 0x14, 0x00, 0x50, 0x14, 0x14, 0x54, 0x14, 0x14, 0x14, 0x00,
0x15, 0x14, 0x14, 0x15, 0x14, 0x14, 0x15, 0x00, 0x50, 0x14, 0x14, 0x50, 0x14, 0x14, 0x50, 0x00,
0x05, 0x14, 0x14, 0x14, 0x14, 0x14, 0x05, 0x00, 0x50, 0x14, 0x00, 0x00, 0x00, 0x14, 0x50, 0x00,
0x15, 0x16, 0x14, 0x14, 0x14, 0x16, 0x15, 0x00, 0x40, 0x50, 0x14, 0x14, 0x14, 0x50, 0x40, 0x00,
0x15, 0x14, 0x14, 0x15, 0x14, 0x14, 0x15, 0x00, 0x54, 0x00, 0x00, 0x54, 0x00, 0x00, 0x54, 0x00,
0x15, 0x14, 0x14, 0x15, 0x14, 0x14, 0x14, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x05, 0x14, 0x14, 0x16, 0x14, 0x14, 0x05, 0x00, 0x50, 0x14, 0x00, 0x54, 0x14, 0x14, 0x50, 0x00,
0x14, 0x14, 0x14, 0x15, 0x14, 0x14, 0x14, 0x00, 0x14, 0x14, 0x14, 0x54, 0x14, 0x14, 0x14, 0x00,
0x15, 0x01, 0x01, 0x01, 0x01, 0x01, 0x15, 0x00, 0x54, 0x40, 0x40, 0x40, 0x40, 0x40, 0x54, 0x00,
0x00, 0x00, 0x00, 0x00, 0x14, 0x14, 0x05, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x50, 0x00,
0x14, 0x16, 0x15, 0x15, 0x15, 0x16, 0x14, 0x00, 0x14, 0x50, 0x40, 0x00, 0x40, 0x50, 0x14, 0x00,
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x00,
0x56, 0x55, 0x59, 0x59, 0x50, 0x50, 0x50, 0x00, 0x50, 0x54, 0x94, 0x94, 0x14, 0x14, 0x14, 0x00,
0x14, 0x15, 0x15, 0x15, 0x16, 0x14, 0x14, 0x00, 0x14, 0x94, 0x54, 0x54, 0x54, 0x14, 0x14, 0x00,
0x05, 0x14, 0x14, 0x14, 0x14, 0x14, 0x05, 0x00, 0x50, 0x14, 0x14, 0x14, 0x14, 0x14, 0x50, 0x00,
0x15, 0x14, 0x14, 0x15, 0x14, 0x14, 0x14, 0x00, 0x50, 0x14, 0x14, 0x50, 0x00, 0x00, 0x00, 0x00,
0x05, 0x14, 0x14, 0x14, 0x14, 0x16, 0x05, 0x00, 0x50, 0x14, 0x14, 0x14, 0x14, 0x50, 0x54, 0x00,
0x15, 0x14, 0x14, 0x15, 0x15, 0x16, 0x14, 0x00, 0x50, 0x14, 0x14, 0x50, 0x40, 0x50, 0x14, 0x00,
0x05, 0x14, 0x14, 0x05, 0x00, 0x14, 0x05, 0x00, 0x50, 0x14, 0x00, 0x50, 0x14, 0x14, 0x50, 0x00,
0x15, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x54, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00,
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x05, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x50, 0x00,
0x14, 0x14, 0x14, 0x14, 0x05, 0x05, 0x01, 0x00, 0x16, 0x16, 0x16, 0x16, 0x50, 0x50, 0x40, 0x00,
0x50, 0x50, 0x59, 0x59, 0x59, 0x55, 0x16, 0x00, 0x14, 0x14, 0x94, 0x94, 0x94, 0x54, 0x50, 0x00,
0x14, 0x14, 0x05, 0x01, 0x05, 0x14, 0x14, 0x00, 0x14, 0x14, 0x50, 0x40, 0x50, 0x14, 0x14, 0x00,
0x14, 0x14, 0x14, 0x05, 0x01, 0x01, 0x01, 0x00, 0x14, 0x14, 0x14, 0x50, 0x40, 0x40, 0x40, 0x00,
0x15, 0x00, 0x00, 0x01, 0x05, 0x14, 0x15, 0x00, 0x54, 0x14, 0x50, 0x40, 0x00, 0x00, 0x54, 0x00,
0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x05, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x05, 0x05, 0x00, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x16, 0x00, 0x01, 0x05, 0x00, 0x05, 0x00, 0x40, 0x50, 0x50, 0x40, 0x00, 0x00, 0x00, 0x00
};

const int font_length = 640;
Binary file added C64/font.koa
Binary file not shown.
Binary file added C64/font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added C64/font_bitmap.bin
Binary file not shown.
Binary file added C64/font_color.bin
Binary file not shown.
Binary file added C64/fontc.bin
Binary file not shown.
Loading

0 comments on commit 1d40719

Please sign in to comment.