87 Commits

Author SHA1 Message Date
39aa6b75a6 example: new maple "get_condition" demo
This is very barebones, and uses the serial interface to communicate
the status of the "a" controller button being pressed.

I'd like to make this a more interactive/graphical demo.
2023-12-15 22:08:23 +08:00
9bd79c6664 maple: remove cruft from maple_wink
This also adds a new overload for align_32byte for integers.
2023-12-15 19:06:59 +08:00
5d1e2f7225 maple: init_block_write depends on 32-bit accesses
The <uint8_t> template instantiation was causing 8-bit writes to the
command buffer, when they were intended to be 32-bit writes. This
garbled and truncated the data ultimately sent to the VMU LCD.
2023-12-15 18:26:30 +08:00
2689ad4011 example: add maple_controller
This broke maple_wink. I have not yet found why this happened.
2023-12-15 17:13:53 +08:00
af07742575 add container.jpg and awesomeface.png 2023-12-15 13:31:00 +08:00
c5078cb030 example: add translucency example
The macaw_multipass example does not work on real hardware.
2023-12-14 20:57:44 +08:00
95a30b5164 example: add macaw_multipass
I don't like this example very much, but it was an interesting
experiment regardless.
2023-12-14 13:07:26 +08:00
9fc40136af example: add sprite example
This also adds ta_parameter_writer; I am not certain if I like this,
but it felt necessary to deal with ta_parameters being either 32 or 64
bytes long--for this reason, a reinterpret_cast to a union is less
attractive (the union members are not a fixed size).
2023-12-13 22:17:02 +08:00
3e9572673c example: add standalone "macaw" example 2023-12-12 22:54:04 +08:00
25e299feba new "example" directory
This is a reshuffling of filenames, extensions, paths, make rules,
just because I felt like it.
2023-12-12 21:50:39 +08:00
855cbba403 maple: write data to a VMU display
This draws a smiley-face bitmap to a VMU display on port 1.
2023-12-11 18:07:05 +08:00
25fef821b0 maple: read controller input on real hardware
There were two notable bugs:

- the maple transfer/data sizes were not being set correctly

- align_32byte always realigned the address of `_scene`, and not the
  `mem` parameter as expected. This had the effect of the maple-DMA
  send and receive buffers being the same buffer. On real hardware,
  this causes unpredicable behavior.
2023-12-10 00:44:33 +08:00
ca77db1734 maple: add maple_host_bits 2023-12-09 17:05:34 +08:00
481a0cb0dc move maple definitions to a new maple/ directory
maple.cpp now uses the new maple_bus_commands.h
2023-12-09 16:38:57 +08:00
c8ed8cdf9e maple: add maple_bus_commands.h 2023-12-09 16:14:21 +08:00
ec09e98757 add vga notes 2023-12-09 11:22:42 +08:00
f1a32d0719 maple: send a 'device request' command
On an emulator, the receive buffer is filled with the correct/expected
data for 'device status'.

I found this experiment useful:

- it revealed a bug in my register struct generator code (the
  maple_if-related registers were not at the correct offsets)

- it validates my understanding about endianness-swapping between the
  maple bus and the SH4
2023-12-09 01:31:34 +08:00
3f30c96dcd add more notes on maple 2023-12-08 11:22:15 +08:00
6cebd0ce90 ta_parameter: TA parameter initialization experiment
This also includes an example for generating a quad primitive. In
flycast, this is very obviously rendered as two triangles. On real
hardware, this appears to be a "native" quad.
2023-12-07 00:46:43 +08:00
9610c428bd draw a textured triangle strip
This draws a nice macaw texture in a square-shaped triangle
strip. The square is then rotated around the y-axis.

I dealt with myriad bugs while experimenting with this, all of them
entirely my fault:

- macaw texture colors were incorrect because GIMP was exporting raw
  RGB data in gamma-corrected sRGB space, whereas the Dreamcast is in
  linear color space.

- macaw texture colors were incorrect because I truncated color values
  to the least significant rather than most significant bits.

- macaw rotation around the Y axis caused the macaw texture to
  distort, stretch and recurse in interesting and unexpected ways. This
  was caused by sending Z values in the wrong coordinate space (Z)
  contrast to what is expected by the Dreamcast (1/z). Reordering
  z-coordinate operations so that the reciprocal is computed last
  resolved this.

- macaw rotation around the Y axis caused the macaw texture to warp
  unexpectedly, but only on real hardware. This was caused by
  unnecessarily negating Z coordinate values.

Behavior for each of the Z-coordinate issues differed between Flycast
and real Dreamcast hardware.

I also did several tests related to SH4 cache behavior, particularly
related to the "copy-back" mode. I verified copy-back behavior on a
real dreamcast, and experimented with the operand cache write-back
instruction, "ocbwb".

In particular, when the `scene` buffer is access from cacheable
memory, e.g: the P1 area, and CCR__CB is enabled, DMA from physical
memory to the TA FIFO polygon converter will fail because the scene
data has not yet been written to physical memory yet. `ocbwb` can be
used to "write back" scene from the SH4 operand cache to physical
memory--only the latter is visible from the CH2-DMA perspective.
2023-12-06 21:18:14 +08:00
bac7618df2 two triangles 2023-12-05 21:53:04 +08:00
a73327c76d fix multiple issues
Successfully tested on real hardware on multiple optimization levels.

I knew in the previous commit that __attribute__((aligned(32))) did
not actually align to 32-bytes. However, at -Os specifically, and only
with that exact code, GCC was coincidentally generating a 32-byte
alignment. When the code or optimization level changed, this changed
the alignment of the "scene" buffer, which caused CH2-DMA to perform
incomplete copies of the TA parameters, which in turn variously caused
the TA to generate incomplete/nonsensical/nonexistent object lists.

This also fixes an unrelated issue with the background ISP/TSP
parameters. This "worked" in flycast but not on real hardware by
complete accident (a coincidence of the specific timing that the
ISP/TSP parameters are read in each Dreamcast implementation). The
issue is that the TSP parameters are 60 bytes long, which is greater
than the 32 bytes were previously being allocated. After changing the
allocation to 64 bytes, the background color is now drawn on real
hardware as expected.

In addition, though this did not cause issues yet, I corrected the
length of p1ram/p2ram in the linker script, to prevent future issues
where GCC's memory allocations wrap around past the end of the system
memory address space.
2023-12-05 20:49:59 +08:00
b99722a6df _bits: use more bits generated from spreadsheets
This rearranges scene.cpp to a file organization that more closely
follows which code is responsible for what area of (hardware)
initialization.

All TA and CORE register accesses now use the new ta_bits.h and
core_bits.h, respectively.
2023-12-05 00:16:38 +08:00
963aa75990 scene: rotating triangle
This now works on real dreamcast hardware.
2023-12-04 09:53:27 +08:00
67f809c98d vga: use core_bits.h 2023-12-02 20:51:48 +08:00
0d8bda28fe add core_bits.csv 2023-12-02 15:20:04 +08:00
bc0b94b437 dummy read from serial before starting serial transfer 2023-12-02 13:35:42 +08:00
37667a4dab regs: add core and ta bits 2023-12-02 12:31:00 +08:00
ff2dcc7d71 draw 1 triangle 2023-11-30 10:02:49 +08:00
060977091d ip.lds: .text.sg.* input section references
The input section names changed from .text. to .text.sg. when the sg object
files were moved to the sg directory.
2023-10-28 10:17:34 -07:00
329ada55f1 add code loading and test program
This was used to troubleshoot video output and framebuffer
configuration registers.
2023-10-16 19:24:51 +00:00
99701f0b57 main: initial vga mode setting
This feels very hacky, and I'd like to make this better.
2023-10-13 05:36:38 -07:00
2bcf1aedef cache: clear all instruction/operand caches 2023-10-12 09:43:54 -07:00
a4ac9fa4c8 systembus.h: initial
This does not yet declare any externs, as I'm not certain how those should work.
2023-10-11 15:39:55 -07:00
ee9e44e4a6 regs: add systembus and memorymap 2023-10-11 15:33:53 -07:00
327e57a520 initial cd image build system 2023-10-11 18:49:58 +00:00
5c4c107eaf add sh7091 and holly registers 2023-10-11 09:01:56 -07:00