Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Nero_3D
- /*
- native wait(time);
- */
- // With SetTimerEx
- // Some variables gets changed while passing the stack to SetTimerEx
- // Reason unknown !
- forward WakeEx(stack[], count, offset, address);
- public WakeEx(stack[], count, offset, address) {
- // storing current frame
- new
- frame
- ;
- // recreating stack
- while(count-- != 1) {
- #emit load.s.alt stack
- #emit load.s.pri count
- #emit shl.c.pri 2
- #emit add
- #emit stor.s.pri frame
- #emit lref.s.pri frame
- #emit push.pri
- }
- // getting first frame
- #emit lctrl 4 // stack
- #emit load.s.alt offset
- #emit add
- #emit stor.s.pri frame
- #emit stor.s.pri count
- // setting the frame pointer to the new stack
- for( ; ; ) {
- #emit lref.s.pri count
- #emit stor.s.pri offset
- if(offset == 0) {
- break;
- } else {
- #emit load.s.pri offset
- #emit load.s.alt count
- #emit add
- #emit stor.i
- #emit stor.s.pri count
- }
- }
- // setting the pointers
- #emit load.s.alt count
- #emit lctrl 5 // frame
- #emit stor.i
- #emit const.pri 4
- #emit add
- #emit move.alt
- #emit lctrl 6 // cip
- #emit add.c 48 // 12
- #emit stor.i
- // setting new frame and jumping back into the code
- #emit load.s.pri frame
- #emit load.s.alt address
- #emit sctrl 5 // frame
- #emit move.pri
- #emit sctrl 6 // cip
- // code will return here
- }
- stock wait(time) {
- new
- current,
- offset,
- count,
- end
- ;
- // getting the stack value before this function
- #emit lctrl 4 // stack
- #emit add.c 32 // 4 vars + 2 pointers + byte + 1 parameter
- #emit stor.s.pri current
- // getting the frame offset
- #emit load.s.alt 0
- #emit sub.alt
- #emit stor.s.pri offset
- // prepare loop
- #emit load.s.pri 0
- #emit stor.s.pri count
- // looping through the frames
- for( ; ; ) {
- // saving the byte offset
- #emit load.s.pri count
- #emit stor.s.pri end
- #emit load.i
- #emit stor.s.pri count
- if(count == 0) {
- break;
- } else {
- #emit load.s.pri count
- #emit load.s.alt end
- #emit sub
- #emit stor.i
- }
- }
- // getting last value to save
- #emit load.s.pri end
- #emit add.c 8
- #emit move.alt
- #emit load.i
- #emit add
- #emit add.c 4
- #emit stor.s.pri end
- // getting count
- #emit load.s.alt current
- #emit sub
- #emit shr.c.pri 2
- #emit stor.s.pri count
- // static
- static const
- func[] = "WakeEx",
- form[] = "aiii"
- ;
- // pushing one more cell
- // because the first cell always gets changed to 1000
- // but it doesnt happen within this function, checked
- count += 1;
- current -= 4;
- // calling the timer
- #emit push.adr 4
- #emit push.adr offset
- #emit push.adr count
- #emit push.s current
- #emit push.c form
- #emit push.c 0
- #emit push.s time
- #emit push.c func
- #emit push.c 32
- #emit sysreq.c SetTimerEx
- // resetting stack
- #emit load.s.pri end
- #emit sctrl 4 // stack
- // change to pointers to zero
- #emit zero.pri
- #emit sctrl 5 // frame
- #emit sctrl 6 // cip
- // end
- }
- // This one works with a global variable
- // Therefore its limited to it
- // But this works flawless
- /*
- new
- gStack[64]
- ;
- forward WakeEx(count, offset, address);
- public WakeEx(count, offset, address) {
- // storing current frame
- new
- frame
- ;
- // recreating stack
- while(count--) {
- #emit const.alt gStack
- #emit load.s.pri count
- #emit lidx
- #emit push.pri
- }
- // getting first frame
- #emit lctrl 4 // stack
- #emit load.s.alt offset
- #emit add
- #emit stor.s.pri frame
- #emit stor.s.pri count
- // setting the frame pointer to the new stack
- for( ; ; ) {
- #emit lref.s.pri count
- #emit stor.s.pri offset
- if(offset == 0) {
- break;
- } else {
- #emit load.s.pri offset
- #emit load.s.alt count
- #emit add
- #emit stor.i
- #emit stor.s.pri count
- }
- }
- // setting the pointers
- #emit load.s.alt count
- #emit lctrl 5 // frame
- #emit stor.i
- #emit const.pri 4
- #emit add
- #emit move.alt
- #emit lctrl 6 // cip
- #emit add.c 48 // 12
- #emit stor.i
- // setting new frame and jumping back into the code
- #emit load.s.pri frame
- #emit load.s.alt address
- #emit sctrl 5 // frame
- #emit move.pri
- #emit sctrl 6 // cip
- // code will return here
- }
- stock wait(time) {
- new
- current,
- offset,
- count,
- end
- ;
- // getting the stack value before this function
- #emit lctrl 4 // stack
- #emit add.c 32 // 4 vars + 2 pointers + byte + 1 parameter
- #emit stor.s.pri current
- // getting the frame offset
- #emit load.s.alt 0
- #emit sub.alt
- #emit stor.s.pri offset
- // prepare loop
- #emit load.s.pri 0
- #emit stor.s.pri count
- // looping through the frames
- for( ; ; ) {
- // saving the byte offset
- #emit load.s.pri count
- #emit stor.s.pri end
- #emit load.i
- #emit stor.s.pri count
- if(count == 0) {
- break;
- } else {
- #emit load.s.pri count
- #emit load.s.alt end
- #emit sub
- #emit stor.i
- }
- }
- // adding the parameters
- #emit load.s.pri end
- #emit add.c 8
- #emit move.alt
- #emit load.i
- #emit add
- #emit add.c 4
- #emit stor.s.pri end
- // storing the whole stack into the heap
- while(current < end) {
- #emit const.pri gStack
- #emit load.s.alt count
- #emit shl.c.alt 2
- #emit add
- #emit move.alt
- #emit lref.s.pri current
- #emit stor.i
- current += 4;
- count++;
- }
- // getting the return
- #emit load.s.pri 4
- #emit stor.s.pri current
- // resetting stack
- #emit load.s.pri end
- #emit sctrl 4 // stack
- // calling the timer
- SetTimerEx("WakeEx", time, false, "iii", count, offset, current);
- // change to pointers to zero
- #emit zero.pri
- #emit sctrl 5 // frame
- #emit sctrl 6 // cip
- // end
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement