|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
More fiddling with Color Print Shop...using a rainbow background. I was integerizing the coordinates, and that wasn't quite right. It looks more like dot matrix output now: ![[Linked Image from i.imgur.com]](https://i.imgur.com/7tnn5UV.png) ![[Linked Image from i.imgur.com]](https://i.imgur.com/amB8ZA5.png) but the file size is huge: 515MB 515665131 Oct 9 18:41 test94.pdf No wonder it takes a minute to render it.
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
![[Linked Image from i.imgur.com]](https://i.imgur.com/QOdVZu8.png) Reproducing this color print shop demo on youtube: https://www.youtube.com/watch?v=z3hMOxR0n5gIt's interesting how the bitmap colors differ from the output pdf where the pdf looks more authentic. I also got the file size a bit smaller (like 10x smaller) by not setting the color for every output dot and by using strokes instead of fills to make the dots.
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
Loading the png into gimp it's pretty easy to manually color correct by adjusting HSL: (split view) ![[Linked Image from i.imgur.com]](https://i.imgur.com/wrYpMcb.png)
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
I just figured out how to directly access members in luaengine, just specify them directly, what could be easier? It's shocking how easy that is... and if you want it read only just make it a property.
device_luaprinter_interface_type.set("xposprop", sol::property(&device_luaprinter_interface::m_lp_xpos));
device_luaprinter_interface_type.set("name", &device_luaprinter_interface::m_lp_luaprintername);
device_luaprinter_interface_type.set("xpos", &device_luaprinter_interface::m_lp_xpos);
So then you can modify the variables directly, like manager:machine().lp[1].xpos = 200
[MAME] function listlp()
[MAME]>> print("listlp() list of luaprinters:")
[MAME]>> print("------------------------------")
[MAME]>> for i,j in pairs(manager:machine().lp) do
[MAME]>> print("lp["..i.."] = "..j:getprintername())
[MAME]>> end
[MAME]>> print("------------------------------")
[MAME]>> end
[MAME]>
[MAME]> listlp()
listlp() list of luaprinters:
------------------------------
lp[1] = 2020-10-12 10-36-18 apple2e-sl1-parallel-pic_ctx-luaprinter
lp[:sl1:parallel:pic_ctx:luaprinter] = 2020-10-12 10-36-18 apple2e-sl1-parallel-pic_ctx-luaprinter
------------------------------
[MAME]> print(manager:machine().lp[1].name)
2020-10-12 10-36-18 apple2e-sl1-parallel-pic_ctx-luaprinter
[MAME]> manager:machine().lp[1].name = "hi_there"
[MAME]> print(manager:machine().lp[1].name)
hi_there
And I was also experimenting with being able to execute lua code from inside the ap2000 driver, so I could call a lua function to say, generate dots for a pdf. So how to execute lua code? Just call load_string.
device_luaprinter_interface_type.set("loadstring", [this](char const *astr)
{ printf("Trying %s\n",astr); return lua_engine::load_string(astr); });
[MAME]> manager:machine().lp[1].loadstring('print("IT WORKS")')
Trying print("IT WORKS")
IT WORKS
[MAME]> function dude(x) print ("This is a function that prints "..x) end
[MAME]> manager:machine().lp[1].loadstring('dude("IT WORKS")')
Trying dude("IT WORKS")
This is a function that prints IT WORKS
So now I need to figure out how to make it possible to call the luaengine from inside the driver. It'd also be cool if you could load_string a string from the debugger, so you could do something complex in lua, so do something similar to a printf but make it lua code to execute.
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
Ok, so I add this to my device_luaprinter_interface: It's a pointer to lua_engine in m_luaengine, and also a pointer to a member function of lua_engine. So I can call the function by ((*m_luaengine).*lualoadstring)(astr); where astr is the string to execute.
static void (lua_engine::* lualoadstring)(const char * astr);
static lua_engine *m_luaengine;
void callloadstring(const char *astr) {
printf("Trying callloadstring %s\n",astr);
((*m_luaengine).*lualoadstring)(astr);
}
and then in luaengine initialize them: device_luaprinter_interface::lualoadstring = &lua_engine::load_string;
device_luaprinter_interface::m_luaengine = this;
so now I can do this: [MAME]> l = manager:machine().lp[1]
[MAME]> l:callloadstring(" l:callloadstring('print(\"whoa!\")') ")
Trying callloadstring l:callloadstring('print("whoa!")')
Trying callloadstring print("whoa!")
whoa!
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
Modifying the dot printing routine to call lua seems to work: char buffer[128];
snprintf(buffer,128,"if drawdot then drawdot( %f, %f ) end",
(double) m_real_cr_pos + CR_OFFSET, yd);
callloadstring( buffer );
I use the if to check if the drawdot routine has been defined.
Trying callloadstring if drawdot then drawdot( 971.000000, 170.333333 ) end
Trying callloadstring if drawdot then drawdot( 971.000000, 171.333333 ) end
Trying callloadstring if drawdot then drawdot( 971.000000, 172.333333 ) end
Trying callloadstring if drawdot then drawdot( 971.000000, 173.333333 ) end
Trying callloadstring if drawdot then drawdot( 971.000000, 174.333333 ) end
and if I define the drawdot routine from the console:
function drawdot(x,y) print("DRAWDOT !!! "..x.." "..y) end
Trying callloadstring if drawdot then drawdot( 35.000000, 60.000000 ) end
DRAWDOT !!! 35.0 60.0
Trying callloadstring if drawdot then drawdot( 35.000000, 61.000000 ) end
DRAWDOT !!! 35.0 61.0
Now I need to figure out how the ap2000 does 240 dpi because the steppers seem to step at 120 dpi, perhaps you have to watch the timing of when the printhead is fired, firing it when it's moving in-between stepper positions.
|
|
|
|
Joined: Oct 2014
Posts: 3
Member
|
Member
Joined: Oct 2014
Posts: 3 |
Now I need to figure out how the ap2000 does 240 dpi because the steppers seem to step at 120 dpi, perhaps you have to watch the timing of when the printhead is fired, firing it when it's moving in-between stepper positions.
The firmware was beautifully written and calculated down to the microseconds it takes for the printhead to hit the paper. Look for two comments which have "417 microseconds" in epson_lx810l.cpp. In epson_lx810l_device::co0_w(): The firmware expects a 300 microseconds delay between the fire signal and the impact of the printhead on the paper. This can be verified by the timings of the steps and fire signals for the same positions with different directions (left to right or right to left). We don't simulate this delay since it is smaller than the time it takes the printhead to travel one pixel (which would be 417 microseconds), so it makes no difference to us. It is interesting to note that the vertical alignment between lines which are being printed in different directions is noticeably off in the 20+ years old printer used for testing =). In epson_lx810l_device::device_timer() The firmware issues two half-steps in sequence, one immediately after the other. At full speed, the motor does two half-steps at each 833 microseconds. A timer fires the printhead twice, with the same period as each half-step (417 microseconds), but with a 356 microseconds delay relative to the motor steps.
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
Hi Raimro, Thanks for the pointers. I stuck some instrumenting in to see the delay between changes to the stepper and the timers. yes the write to co0_w is 417 ms apart: (2525-2107 = 418) POS = 0 DATA=0
POS = 1 DATA=0
STEPPER:d
CR_STEPPER_MSECS: time = 835.9782 microsecs
CR_STEPPER current pos: -49
POS = 0 DATA=0
POS = 1 DATA=0
CR_TIMER_MSECS: time = 835.978
POS = 0 DATA=0
POS = 1 DATA=44
Fractional time co0_w: 152107.340486
Trying callloadstring if drawdot then drawdot( 33.000000, 25.333333 ) end
Fractional time co0_w: 152107.340486
Trying callloadstring if drawdot then drawdot( 33.000000, 29.333333 ) end
STEPPER:8
CR_STEPPER_MSECS: time = 830.0781 microsecs
CR_STEPPER current pos: -48
POS = 0 DATA=0
POS = 1 DATA=38
Fractional time co0_w: 152525.024406
Trying callloadstring if drawdot then drawdot( 33.000000, 26.333333 ) end
Fractional time co0_w: 152525.024406
Trying callloadstring if drawdot then drawdot( 33.000000, 27.333333 ) end
Fractional time co0_w: 152525.024406
Trying callloadstring if drawdot then drawdot( 33.000000, 28.333333 ) end
CR_TIMER_MSECS: time = 830.078
Gonna have to study this some more 8-)
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
and checking the time since the last stepper change, it says 337 usec and 755 usec (755-337 usec = 418 usec) so yes very close to expected POS = 0 DATA=0
POS = 1 DATA=20
Fractional time co0_w: 110442.708325
Time since last step: 757.446289
Trying callloadstring if drawdot then drawdot( 83.000000, 26.333333 ) end
STEPPER:5
CR_STEPPER_MSECS: time = 833.9437 microsecs
CR_STEPPER current pos: -98
POS = 0 DATA=0
POS = 1 DATA=8
Fractional time co0_w: 110857.137036
Time since last step: 337.931315
Trying callloadstring if drawdot then drawdot( 83.000000, 28.333333 ) end
CR_TIMER_MSECS: time = 833.944
POS = 0 DATA=0
POS = 1 DATA=20
Fractional time co0_w: 111274.210604
Time since last step: 755.004883
Trying callloadstring if drawdot then drawdot( 82.000000, 26.333333 ) end
STEPPER:d
CR_STEPPER_MSECS: time = 831.5023 microsecs
CR_STEPPER current pos: -97
POS = 0 DATA=0
POS = 1 DATA=8
Fractional time co0_w: 111690.470369
Time since last step: 339.762370
Trying callloadstring if drawdot then drawdot( 82.000000, 28.333333 ) end
CR_TIMER_MSECS: time = 831.502
POS = 0 DATA=0
POS = 1 DATA=2
Fractional time co0_w: 112107.543937
Time since last step: 756.835937
Trying callloadstring if drawdot then drawdot( 81.000000, 30.333333 ) end
STEPPER:8
CR_STEPPER_MSECS: time = 833.3333 microsecs
|
|
|
|
Joined: Mar 2001
Posts: 16,892 Likes: 51
Very Senior Member
|
Very Senior Member
Joined: Mar 2001
Posts: 16,892 Likes: 51 |
Reading this makes me realize how much a dot-matrix printer is like a write-only floppy drive, except it controls the exact media position instead of waiting for it to come around to the right spot.
|
|
|
3 members (mixmaster, r09, 1 invisible),
21
guests, and
3
robots. |
Key:
Admin,
Global Mod,
Mod
|
|
Forums9
Topics9,072
Posts118,947
Members5,014
|
Most Online890 Jan 17th, 2020
|
|
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!
|
|
|
|