Skip to content

Commit

Permalink
two screens, rle support
Browse files Browse the repository at this point in the history
  • Loading branch information
pronopython committed Feb 19, 2024
1 parent a0e5a62 commit 2e1a792
Show file tree
Hide file tree
Showing 10 changed files with 828 additions and 131 deletions.
94 changes: 83 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Ever wondered how your *pron* stash would have looked on floppy disk?

Try it out with HypraFap!

With HypraFap you can store and view 16 beautiful color images per disk side on your Commodore 64!
With HypraFap you can store and view about 16 beautiful color images per disk side on your Commodore 64!

![](img/3.png)

Expand Down Expand Up @@ -76,6 +76,11 @@ You can directly select an image by pressing its number/letter. Press `5` to jum

Press `0` or `i` (as in index) to jump back to the index image.

Now press `F3` to switch to the second screen and load image number 3 by pressing `3`.

![](img/10.jpg)

You then can switch back to screen 1 (with the index) by pressing `F1`. Jump back and forth between both screens. Everytime you press an image number or space, hyprafap loads the image to the currently selected screen.

While loading the next screen the old image is visible and you can see how it is overwritten with new image data.
This is intentional (you know HypraFap is doing something).
Expand All @@ -88,23 +93,26 @@ See here how the next image is faintly visible on the top half (a face in the mi

![](img/1.jpg)

If you load a compressed Koala image (`.gg`), you cannot see how it is loaded because the data is loaded off screen to a buffer for decompressing.

## Swap Disk

If you have multiple disks with images, you can swap a disk out anytime while no drive access happens.

Press `R` to reload the directory of the new disk and access the images on it.

Also, when you start HypraFap as a standalone `.prg` in VICE and thus no image is loaded at startup, use `R` to switch to and load an image disk.

# Keyboard Commands

| key | command |
|---|---|
| `0`-`9`, `A`-`F`| Load image 0..15|
| `I` | Load first image / number 0 (index / gallery)|
| `0`-`9`, `A`-`H`| Load image 0..17 to current screen|
| `I` | Load first image / number 0 (index / gallery) to current screen|
| `Space` | next image |
| `R` | Reload directory after disk swap. Loads first image on new disk|


![](img/10.jpg)
| `R` | Reload directory after disk swap. Loads first image on new disk to current screen|
| f1 | Switch to screen 1|
| f3 | Switch to screen 2|

# Making your own HypraFap disks

Expand All @@ -118,6 +126,8 @@ HypraFap uses standard uncompressed Koala Painter images produced by a lot of pr

to convert `.jpg` / `.png` files to `.koa` files.

You can also use RLE-compressed Koala Painter images (`.gg`), which you can convert from `.koa` files with different programs like [Pixcen](https://csdb.dk/release/?id=149752). This will typically make room for 1 more image per disk side.

### Image aspect ratio

Note that the pixels are not perfectly square on a C64.
Expand Down Expand Up @@ -145,13 +155,13 @@ See how the Demo Disk looks like:

![](img/directory.png)

Images *need* to have the name ending in `.koa` for HypraFap to recognize them!
Images *need* to have the name ending in `.koa` (uncompressed) or `.gg` (compressed) for HypraFap to recognize them!

Add up to 16 Koala images per disk!
Add up to 16 Koala images per disk uncompressed or 17-18 compressed!

## Index image template

Index pages are just koala pictures like all the other pictures on the disks. An index images has to be the first image in the directory with the ending `.koa`.
Index pages are just koala pictures like all the other pictures on the disks. An index images has to be the first image in the directory with the ending `.koa` or `.gg`.

You can use this template for your index image:

Expand Down Expand Up @@ -182,6 +192,46 @@ If you have the linux bin in the same directory (src) as the `.asm` files run:

to compile HypraFap.

# Technical specification of the Compressed Koala Painter Format (.gg)

> :eggplant: :sweat_drops: *Note: This is retrived through reverse engineering*
Koala Painter files with extension .gg are RLE compressed as follows:

Starting at byte number 3 to skip the first two load address bytes ($00 $60), if 3 or more bytes are identical, these are replaced by

`$FE [identical byte] [number of repetitions]`

`[number of repetitions]` can be between $00 and $FF ($00 represents 256 repetitions)

If $FE is found in the source bytes it is compressed, even when it only occures one time (one occurents of $FE results in bytes: `$FE $FE $01`). This can in rare occurences make the file larger than uncompressed.

The load address' second byte $60 is not compressed even when several $60 bytes follow. Only the bytes starting at 3rd position are compressed -- thus only the image information is compressed! This makes sense as otherwise a load of a .gg file would fail in rare cases.

(That $00 represents 256 repetitions is not mentioned in other documentations!)

# Memory map of HypraFap

| address | for Screen| Description|
|----|----|---|
|$0400|Screen 1|Screen RAM|
|$0801| |HypraFap program code|
|$2000|Screen 1|Bitmap|
|$3f40|Screen 1|Screen Data|
|$4328|Screen 1|Color Data|
|$4710|Screen 1|Color 0|
|$5c00|Screen 2|Screen RAM|
|$6000|Screen 2|Bitmap|
|$7f40|Screen 2|Screen Data|
|$8328|Screen 2|Color Data|
|$8710|Screen 2|Color 0|
|$9000|Buffer 1|RLE Load Buffer|
|$c320| |Number of images, other variables|
|$c581| |Directory entries|
|$d800| |Color RAM|

See `headers.asm` for all labels in use.

# Know bugs & limitations

- "Loading" message is written to screen ram, color changes in the old image partially when load is started. Since the old image is overwritten, that is not that of a problem.
Expand All @@ -194,13 +244,35 @@ to compile HypraFap.
|---------|---|
|It is slow!| Yes, the data transfer between disk drive and computer is 400 bytes (!) per second. A 10kB Koala image takes about 25 seconds to load. You can speed this up with a fastloader, see above.|

# 📢 Community Support

The [GitHub discussion boards](https://github.com/pronopython/hyprafap/discussions) are open for sharing ideas and plans for HypraFap.

You can report errors through a [GitHub issue](https://github.com/pronopython/hyprafap/issues/new).

Don't want to use GitHub? You can also contact me via email: [email protected] If you want to contact me anonymously, create yourself a burner email account.

# Release Notes

## v0.2.0-alpha

### added

- 2 Screens available: Swicht between them with f1/f3
- .gg file support with RLE decompression

### changed

- Pictures are now numbered 0-9,A-H (18 total) to accomodate 1 or 2 more pictures through RLE compression

### fixed

- Crash when no image is present on startup

## v0.1.0-alpha

- Initial Release

# Why?

For me this is just a weekend fun project to learn a bit 6502 assembly language on an 8 bit computer :-)
For me this is just a weekend fun project to learn a bit 6502 assembly language on an 8 bit computer :-)
Binary file modified hyprafap.prg
Binary file not shown.
Binary file modified hyprafap_demo_disk.d64
Binary file not shown.
65 changes: 60 additions & 5 deletions src/control.asm
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ cycle_images
sta current_image

loop_cycle_image
lda current_image
jsr load_image_by_number
lda number_of_images
beq no_images
lda current_image
jsr load_image_by_number
no_images
cycle_images_scan_key_loop

Expand Down Expand Up @@ -64,7 +67,8 @@ cycle_images
jmp cycle_images_scan_key_loop

check_letter
cmp #71 ; "g" (one after "f")
;cmp #71 ; "g" (one after "f")
cmp #73 ; "i" (one after "h")
bcc handle_letter

; == I ==
Expand All @@ -75,6 +79,12 @@ cycle_images
cmp #82 ; "R"
beq keypress_R

cmp #133 ; f1
beq keypress_f1

cmp #134 ; f3
beq keypress_f3

jmp cycle_images_scan_key_loop ; no supported keypress

; == handle calculated keys (0-9,a-f) ==
Expand Down Expand Up @@ -111,7 +121,15 @@ cycle_images
lda #0
sta current_image
jmp loop_cycle_image
keypress_f1
jsr show_screen_1
jmp cycle_images_scan_key_loop

keypress_f3
jsr show_screen_2
jmp cycle_images_scan_key_loop

check_biggest_image_number
lda current_image
sec
Expand All @@ -125,13 +143,50 @@ cycle_images
load_image_by_number
; A: image number (0..number of images - 1)
; uses $FB,$FC,$FD
sta $FD

sta $FD ; remember image number

tay
lda image_types, y
cmp #$0
beq load_uncompressed

lda #$3 ; load into buffer
sta $FE

lda $FD
jsr get_filename_pointer
lda $FD
jsr calculate_image_filename_length
ldx $FB
ldy $FC

jsr load_image

lda active_shown_screen
jsr decompress_buffer
jsr show_selected_screen_after_load

rts


load_uncompressed

lda active_shown_screen
sta $FE

lda $FD
jsr get_filename_pointer
lda $FD
jsr calculate_image_filename_length
ldx $FB
ldy $FC


jsr load_image

jsr show_selected_screen_after_load

rts

calculate_image_filename_length
Expand Down
Loading

0 comments on commit 2e1a792

Please sign in to comment.