Mostrando las entradas con la etiqueta matemáticas. Mostrar todas las entradas
Mostrando las entradas con la etiqueta matemáticas. Mostrar todas las entradas

lunes, 10 de agosto de 2026

Circulos, Lineas Bresenham

Una necesidad/pregunta recurrente de antaño es como dibujar de forma rapida y correcta lineas y circulos y Bresenham lo hizo cuando trabajaba para IBM basandise en Midpoint circle algorithm, y depsues aparecieron varias forks.

https://web.archive.org/web/20260414031310/https://schwarzers.com/algorithms/

https://en.wikipedia.org/wiki/Bresenham's_line_algorithm

https://en.wikipedia.org/wiki/Midpoint_circle_algorithm

100 GRAPHICS 8
110 COLOR 1
120 A=160
130 B=80
140 R=50

150 X=0
160 Y=R
170 U=0
180 V=4*Y
190 D=3-2*R

200 IF D>=0 THEN 250

210 GOTO 280

250 D=D+4-V
260 V=V-4
270 Y=Y-1

280 PLOT A+X,B+Y
290 PLOT A+X,B-Y
300 PLOT A-X,B+Y
310 PLOT A-X,B-Y
320 PLOT A+Y,B+X
330 PLOT A+Y,B-X
340 PLOT A-Y,B+X
350 PLOT A-Y,B-X

360 D=D+6+U
370 U=U+4
380 X=X+1

390 IF X<=Y THEN 200

 

https://forums.atariage.com/topic/306038-fast-atari-basic-circle/

 

https://forums.atariage.com/topic/301993-missile-command/

I've been reverse-engineering Missile Command off and on. It's one of the many on my to do list.

 

Rob does a similar technique of a linear question found in Activision's Laser Blast, Fishing Derby, and Pitfall!

 

Look at my reverse-engineering of Laser Blast. It may help.

 

Start looking at label .determineAttackerLaserDirection. This is where David Crane determines the direction of the attacker laser and the slope. Then in the kernel at .drawLeadShipKernel he uses the tankLaserSlopeFractionValue to increment tankLaserSlopeIntegerValue. When a carry is determined (i.e. time to increment the integer value) he sets the HMM1 register to fine adjust the tanks laser.

 

Despues salio un algoritmo con antialiasing:

https://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm

 



https://manillismo.blogspot.com/2024/11/compu-programas-atari-utilitarios.html

 

sábado, 30 de mayo de 2026

sábado, 25 de abril de 2026

El Requerimiento Imposible Fractalico

 El requerimiento imposible de la revists Antic:

 (Kudos to any programmer who finds a way to replace the self-squaring loop-in lines 310-400-with one or two mathematic equations. The equations should accept variables AZ, BZ, AC, BC and return a COUNT value. An algebraic proof of the equations must also be submitted. The best solution, in the judgement of the editors, will be published in these pages. -ANTIC ED)

 





http://www.atarimagazines.com/v4n12/FractalZoom.html

https://forums.atariage.com/topic/263988-fractal-zoom/

 

jueves, 8 de enero de 2026

Flight of Loren

Tributo a Loren Carpenter.



Fractal Flight 6502 Engine - Core Features
 
  1. "Rescue on Fractalus" Rendering: Implements a Voxel/Height-map rendering technique using a bottom-up "Limit Buffer" (painter's algorithm) to correctly handle mountain occlusion without a Z-buffer.
  2. Pseudo-Roll Effect: Simulates 3D camera banking efficiently using a "Tilt Table" that applies a vertical shear to screen columns, creating a convincing roll illusion without expensive 3D rotation math.
  3. Integrated Music: Features a built-in SAP music player ("Behind Jaggi Lines") that runs on the Vertical Blank Interrupt (VBL), fully synchronized with the game loop.
  4. Procedural Terrain System: Generates a 16x16 world grid with fractal roughness "seeds" and specific gameplay objects like "Bunkers" (marked via bit flags).
  5. Smart Terrain Following: Includes a collision avoidance system that "looks ahead" to automatically adjust the camera's altitude, preventing crashes into terrain features.
  6. Fixed-Point Physics: Utilizes 16.16 fixed-point precision for altitude (allowing distinct valley floors vs. mountain peaks) and 8.8 precision for lateral movement.
  7. Visual Effects System: Features a multi-stage "Hit Flash" reaction (progressing from Bright -> Mid -> Low-Fade) and a Green Laser drawing algorithm with perspective-based thickness.
  8. Double-Buffered Rendering: Uses a generic Double Buffering scheme (swapping DLI pointers and VRAM offsets $8000/$9000) to ensure flicker-free animation at high frame rates.
  9. Diagnostic Test Suite: Contains 6 built-in distinct "Modes" for isolating and debugging specific subsystems, such as math sorting, projection calibration, and fractal line generation.
  10. Joystick Flight Control: Replaces keyboard input with full Joystick support, including auto-centering logic that returns the ship to level flight when controls are released.

Mathematical & FOV Implementation Details:

  1.  FOV-Driven Scale Table Hack: Uses a pre-calculated reciprocal table (1/Z) multiplied by a Field of View constant (default #70) to project 3D points without slow 6502 division.
  2. Iterative Grid Transformation: Instead of matrix multiplication for every node, it calculates "Step Vectors" (U and V) once and transforms the 8x8 grid using only additions, significantly boosting performance.
  3. Pseudo-Roll Shear Effect: Simulates camera banking using a "Tilt Table" that applies a vertical shear to screen columns, creating a 3D roll illusion purely in screen space.
  4. Recursive Midpoint Displacement: Recreates the "Fractalus" mountain look by recursively subdividing lines and displacing the midpoint based on world-space "seeds" (tags).
  5. Quarter-Square Multiplication: Implements high-speed 16-bit signed multiplication using squaring tables ((sum)^2/4 - (diff)^2/4) for rotation and laser physics.
  6. Limit-Buffer Occlusion: A bottom-up Y-buffer ("line_pixel_height_buffer") tracks the horizon for every column, ensuring correct painter's algorithm occlusion.
  7. Procedural Ridge Walkers: Generates a 16x16 wrapping world using "Walkers" with momentum, creating natural connected mountain ranges rather than random noise.
  8. High-Precision 16.16 Altitude: The camera uses 32-bit fixed-point altitude for smooth terrain following and vertical collision avoidance.
  9. DDA-Based Perspective Lasers: Draws laser beams with 16-bit DDA slopes and perspective-correct thickness that scales as it moves toward the player.
  10. Integrated Music Engine: Features an interrupt-driven playback of "Behind Jaggi Lines," synchronized with the game logic and handling Zero Page sharing between the player and the engine.

Geometry Clipping & Frustum Management:

  1. Robust 3D Z-Near Clipping: Prevents mathematical warping and projection overflows by strictly rejecting or clipping points that are behind the camera or too close to the near plane (Z < 1.0).
  2. 2D Cohen-Sutherland Algorithm: Implements a classic screen-space clipping system using 4-bit bitwise outcodes for rapid trivial rejection or acceptance of line segments.
  3. Binary Search Intersector: Instead of expensive 16-bit division to find line-edge intersections, the engine uses a midpoint subdivision (binary search) strategy that reaches sub-pixel precision in just 8 iterations.

 

https://forums.atariage.com/topic/387215-flight-of-loren-a-tribute-to-loren-carpenter-rip/