Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
first time rendering images and stuff. # this is not optimal. lol.
- Loading branch information
Showing
with
24 additions
and
8 deletions.
-
+1
−0
lib/mimey/emulator.rb
-
+5
−2
lib/mimey/gpu.rb
-
+6
−4
lib/mimey/lcd_screen.rb
-
+12
−2
test_emulator.rb
|
@@ -4,6 +4,7 @@ module Mimey |
|
|
class Emulator |
|
|
attr_accessor :debug_mode, :step_by_step, :step_counter |
|
|
attr_reader :screen |
|
|
attr_reader :gpu # delete this later |
|
|
|
|
|
def initialize(cpu_options = {}) |
|
|
cpu_options = CPU::DEFAULTS.merge(cpu_options) |
|
|
|
@@ -3,6 +3,7 @@ module Mimey |
|
|
class GPU |
|
|
attr_reader :vram |
|
|
attr_accessor :cpu |
|
|
attr_reader :scrn # delete this later |
|
|
|
|
|
def initialize(screen) |
|
|
@screen = screen |
|
@@ -306,7 +307,8 @@ def new_renderscan |
|
|
tilerow = @tilemap[tile][y] |
|
|
160.downto(1).each do |w| |
|
|
@scanrow[160 - x] = tilerow[x] |
|
|
@scrn[linebase + 3] = @palette[:bg][tilerow[x]] |
|
|
# by some reason we have to divide this by 4. don't ask me why. |
|
|
@scrn[(linebase + 3)/4] = @palette[:bg][tilerow[x]] |
|
|
x += 1 |
|
|
if x == 8 then |
|
|
t = (t + 1) & 31 |
|
@@ -323,7 +325,8 @@ def new_renderscan |
|
|
tilerow = @tilemap[@vram[mapbase + t]][y] |
|
|
160.downto(1).each do |w| |
|
|
@scanrow[160 - x] = tilerow[x] |
|
|
@scrn[linebase + 3] = @palette[:bg][tilerow[x]] |
|
|
# by some reason we have to divide this by 4. don't ask me why. |
|
|
@scrn[(linebase + 3)/4] = @palette[:bg][tilerow[x]] |
|
|
x += 1 |
|
|
if x == 8 then |
|
|
t = (t + 1) & 31 |
|
|
|
@@ -11,6 +11,8 @@ class LcdScreen |
|
|
0 => 3 |
|
|
} |
|
|
|
|
|
attr_accessor :screen |
|
|
|
|
|
def initialize |
|
|
@screen = (WIDTH * HEIGHT).times.map { 0 } |
|
|
end |
|
@@ -25,8 +27,8 @@ def render |
|
|
|
|
|
def []=(coords, color) |
|
|
return unless color |
|
|
color_index = COLOR_MAPPINGS[color] |
|
|
@screen[coords] = COLORS[color_index] |
|
|
# i want to do it this way so I can set @screen to @scrn |
|
|
@screen[coords] = color |
|
|
# x, y = coords |
|
|
# if x < WIDTH and y < HEIGHT |
|
|
# @screen[y * WIDTH + x] = color_code |
|
@@ -37,8 +39,8 @@ def []=(coords, color) |
|
|
# https://github.com/fazibear/colorize/blob/master/lib/colorize.rb |
|
|
# http://misc.flogisoft.com/bash/tip_colors_and_formatting |
|
|
def print_pixel(color) |
|
|
# code = COLORS[color] |
|
|
code = color |
|
|
# this is not optimal. lol. |
|
|
code = COLORS[COLOR_MAPPINGS[color]] |
|
|
print "\e[49m\e[#{code}m \e[49m" |
|
|
end |
|
|
end |
|
|
|
@@ -106,8 +106,18 @@ def reference_hash |
|
|
else |
|
|
puts "ran #{step_counter.steps.length} steps" |
|
|
puts "OMG I couldn't find any errors!" |
|
|
puts step_counter.steps.last.gpu_r.scrn.inspect |
|
|
# emulator.screen.render |
|
|
screen = Mimey::LcdScreen.new |
|
|
scrn = emulator.gpu.scrn |
|
|
if scrn.compact.length != scrn.length then |
|
|
puts "warning, the screen has some nils" |
|
|
puts scrn.length |
|
|
puts scrn.compact.length |
|
|
puts scrn[0..100].inspect |
|
|
puts scrn[0..100].compact.inspect |
|
|
end |
|
|
|
|
|
screen.screen = scrn |
|
|
screen.render |
|
|
end |
|
|
|
|
|
# emulator.debug |