Skip to content

Commit

Permalink
refactor some code
Browse files Browse the repository at this point in the history
  • Loading branch information
MESYETI committed Nov 16, 2023
1 parent 903988b commit bcfaec2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions demos/lines.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ loop:
set d 0
cmp b d
; draws black if its even
jnzb draw_black
jnz draw_black
; and white if its odd
set b 15
jmpb next
jmp next

draw_black:
set b 0
Expand All @@ -32,8 +32,8 @@ next:
set b 0
; checks if rendered every pixel
cmp c b
jnzb end
jmpb loop
jnz end
jmp loop

end:
jmpb end
jmp end
17 changes: 10 additions & 7 deletions source/display.d
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,23 @@ class Display {
break;
}
case 0x10: {
ubyte[256 * 3] paletteData = computer.ram[0x00FE05 .. 0x10105];
uint paletteAddr = 0x00FE05;
uint pixelAddr = 0x000405;
uint pixelEnd = pixelAddr + (320 * 200);

SDL_SetRenderDrawColor(
renderer, paletteData[0], paletteData[1], paletteData[2], 255
renderer, computer.ram[paletteAddr], computer.ram[paletteAddr + 1],
computer.ram[paletteAddr + 2], 255
);
SDL_RenderClear(renderer);

for (uint i = 0x000405; i < 0x00FE05; ++ i) {
uint offset = i - 0x000405;
for (uint i = pixelAddr; i < pixelEnd; ++ i) {
uint offset = i - pixelAddr;
ubyte colour = computer.ram[i];
pixels[offset] = ColourToInt(
paletteData[colour * 3],
paletteData[(colour * 3) + 1],
paletteData[(colour * 3) + 2]
computer.ram[paletteAddr + (colour * 3)],
computer.ram[paletteAddr + (colour * 3) + 1],
computer.ram[paletteAddr + (colour * 3) + 2]
);
}
break;
Expand Down

0 comments on commit bcfaec2

Please sign in to comment.