Skip to content

Commit

Permalink
refresh emulation: only update areas that are refreshed
Browse files Browse the repository at this point in the history
when refresh emulation is enabled, only the parts of the screen
are actually updated that are being refreshed. This allows to
debug refresh regions with the emulator.
Reminder: activate refresh emulation by setting the environment
variable EMULATE_READER_FLASH to the number of milliseconds that
you want the inverse flash to endure. Suggested are now about
100 (msecs).
  • Loading branch information
hwhw committed Nov 30, 2014
1 parent ce84769 commit e135c5e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
23 changes: 18 additions & 5 deletions ffi/framebuffer_SDL1_2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@ local SDL = require("ffi/SDL1_2")
local BB = require("ffi/blitbuffer")
local util = require("ffi/util")

local framebuffer = {}
local framebuffer = {
-- this blitbuffer will be used when we use refresh emulation
sdl_bb = nil,
}

function framebuffer:init()
if not self.dummy then
SDL.open()
-- we present this buffer to the outside
self.bb = BB.new(SDL.screen.w, SDL.screen.h, BB.TYPE_BBRGB32,
local bb = BB.new(SDL.screen.w, SDL.screen.h, BB.TYPE_BBRGB32,
SDL.screen.pixels, SDL.screen.pitch)
local flash = os.getenv("EMULATE_READER_FLASH")
if flash then
-- in refresh emulation mode, we use a shadow blitbuffer
-- and blit refresh areas from it.
self.sdl_bb = bb
self.bb = BB.new(SDL.screen.w, SDL.screen.h, BB.TYPE_BBRGB32)
else
self.bb = bb
end
else
self.bb = BB.new(600, 800)
end
Expand Down Expand Up @@ -46,10 +57,12 @@ function framebuffer:refreshFullImp(x, y, w, h)

local flash = os.getenv("EMULATE_READER_FLASH")
if flash then
bb:invertRect(x, y, w, h)
self.sdl_bb:invertRect(x, y, w, h)
flip()
util.usleep(tonumber(flash)*1000)
bb:invertRect(x, y, w, h)
self.sdl_bb:setRotation(bb:getRotation())
self.sdl_bb:setInverse(bb:getInverse())
self.sdl_bb:blitFrom(bb, x, y, x, y, w, h)
end

flip()
Expand Down
22 changes: 18 additions & 4 deletions ffi/framebuffer_SDL2_0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ local SDL = require("ffi/SDL2_0")
local BB = require("ffi/blitbuffer")
local util = require("ffi/util")

local framebuffer = {}
local framebuffer = {
-- this blitbuffer will be used when we use refresh emulation
sdl_bb = nil,
}

function framebuffer:init()
if not self.dummy then
SDL.open()
-- we present this buffer to the outside
self.bb = BB.new(SDL.w, SDL.h, BB.TYPE_BBRGB32)
local bb = BB.new(SDL.w, SDL.h, BB.TYPE_BBRGB32)
local flash = os.getenv("EMULATE_READER_FLASH")
if flash then
-- in refresh emulation mode, we use a shadow blitbuffer
-- and blit refresh areas from it.
self.sdl_bb = bb
self.bb = BB.new(SDL.w, SDL.h, BB.TYPE_BBRGB32)
else
self.bb = bb
end
else
self.bb = BB.new(600, 800)
end
Expand Down Expand Up @@ -43,10 +55,12 @@ function framebuffer:refreshFullImp()

local flash = os.getenv("EMULATE_READER_FLASH")
if flash then
bb:invertRect(x, y, w, h)
self.sdl_bb:invertRect(x, y, w, h)
render(bb)
util.usleep(tonumber(flash)*1000)
bb:invertRect(x, y, w, h)
self.sdl_bb:setRotation(bb:getRotation())
self.sdl_bb:setInverse(bb:getInverse())
self.sdl_bb:blitFrom(bb, x, y, x, y, w, h)
end
render(bb)
end
Expand Down

0 comments on commit e135c5e

Please sign in to comment.