30 Commits

Author SHA1 Message Date
e8aea009c6 example: add heart
I originally planned to make this a render-to-texture demo, but this
is fairly interesting by itself.
2023-12-31 20:19:41 +08:00
549254615e example: modifier_volume_with_two_volumes 2023-12-30 21:50:54 +08:00
de76c0bed2 ta_parameter_format: generate TA parameter formats from csv
This replaces all handwritten TA parameter format structures with
automatically generated structures.

All valid TA parameter formats are now declared.
2023-12-30 18:55:09 +08:00
5db6272ceb example: add modifier volume
This creates a modifier volume with a cube that intersects a plane.
2023-12-30 15:11:22 +08:00
2a721d8c01 core: enable span/offset sort 2023-12-25 23:41:11 +08:00
6f010c20f5 core: remove flycast hack
I think this was only relevant when END_OF_RENDER_VIDEO was in use;
this doesn't seem to affect flycast's END_OF_RENDER_TSP
generation. The former is definitely a flycast bug.
2023-12-25 22:17:07 +08:00
54f09bad01 ta_fifo_polygon_converter: properly calculate ta_next_opb_offset
The main issue with the previous code:

  constexpr uint32_t tiles = (640 / 32) * (320 / 32);

Should have been:

  constexpr uint32_t tiles = (640 / 32) * (480 / 32);

The consequence of this is some OPBs were being overwritten by
TA_NEXT_OPB, causing corruption (missing triangles, incomplete
drawings) in some tiles.
2023-12-25 21:59:26 +08:00
03aa9b27f0 core: set correct pointer_burst_size
0x15 is 21, which is larger than the OPB size (16).

The 0x15 value directly causes CORE to hang given a sufficiently
"large" object list (more than ~2 triangles per tile).

After changing pointer burst size to the intended value, 15, CORE no
longer hangs while drawing "large" object lists.
2023-12-25 00:54:54 +08:00
befedb9d38 example: add lighted cube
This also copy-pastes all of the math headers I originally wrote in
saturn-examples.
2023-12-24 16:24:27 +08:00
3373ea4c0c font_outline_punch_through: implement punch through
This enables alpha blending for both font_outline and
font_outline_punch_through.

I have also experimented more with 16-gray vs 256-gray--I have not
decided which between monochrome, 16-gray, or 256-gray I like the
most.

Perhaps a better test might be to test hanzi.
2023-12-24 01:12:08 +08:00
8f0afc2868 font_outline: remove all 1024/256/128 magic numbers
This fully threads both the real minimum size of the texture and the
dimensions of the texture through to the TA parameters.

This also removes spurious zero-area drawing commands (space
characters).
2023-12-22 23:54:39 +08:00
e2a6406a05 example: add macaw_cube_render_to_texture 2023-12-18 02:10:52 +08:00
5c2b45b70d example: refresh
All examples work again, except macaw_multipass--this never worked
entirely, so I'm not worried about fixing it at the moment.
2023-12-17 22:45:52 +08:00
aa805468d9 holly/core: use End of TSP interrupt
Core bug #20 is real:

  The "End_Of_Video" interrupt is sometimes not output.

  Replace with "End_Of_TSP
2023-12-17 22:09:03 +08:00
59f8c1b3ff cube: a perspective cube 2023-12-17 17:04:34 +08:00
5a9790daf1 examples: add font example 2023-12-17 02:03:42 +08:00
7daff7e3ca example: add macaw_twiddle 2023-12-16 23:28:28 +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
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
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
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
ff2dcc7d71 draw 1 triangle 2023-11-30 10:02:49 +08:00